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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
letsgoING
ArduBlock Source
Simulator
Commits
50b40ecc
Commit
50b40ecc
authored
4 years ago
by
Leon Dieter
Browse files
Options
Downloads
Patches
Plain Diff
Buttons scalable / window scalable
parent
9aa2d05d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/tec/letsgoing/ardublock/simulator/view/GUI.java
+5
-5
5 additions, 5 deletions
src/tec/letsgoing/ardublock/simulator/view/GUI.java
src/tec/letsgoing/ardublock/simulator/view/modules/Button.java
+37
-7
37 additions, 7 deletions
...ec/letsgoing/ardublock/simulator/view/modules/Button.java
with
42 additions
and
12 deletions
src/tec/letsgoing/ardublock/simulator/view/GUI.java
+
5
−
5
View file @
50b40ecc
...
@@ -135,16 +135,16 @@ public class GUI extends JFrame implements Runnable, ActionListener {
...
@@ -135,16 +135,16 @@ public class GUI extends JFrame implements Runnable, ActionListener {
@Override
@Override
public
void
componentResized
(
ComponentEvent
e
)
{
public
void
componentResized
(
ComponentEvent
e
)
{
if
(
Math
.
abs
(
WindowHeight
-
getHeight
())
>
30
||
Math
.
abs
(
WindowWidth
-
getWidth
())
>
30
)
{
System
.
out
.
println
(
"boom.."
);
WindowHeight
=
getHeight
();
WindowHeight
=
getHeight
();
WindowWidth
=
getWidth
();
WindowWidth
=
getWidth
();
topPanelWidth
=
topPanel
.
getWidth
();
topPanelWidth
=
topPanel
.
getWidth
();
topPanelHeight
=
topPanel
.
getHeight
();
topPanelHeight
=
topPanel
.
getHeight
();
if
(
topPanelWidth
<=
((
topPanelHeight
+
WindowHeight
)
/
2
))
{
if
(
topPanelWidth
<=
((
topPanelHeight
+
WindowHeight
)
/
2
))
{
xscale
=
topPanelWidth
;
xscale
=
topPanelWidth
;
...
@@ -158,7 +158,7 @@ public class GUI extends JFrame implements Runnable, ActionListener {
...
@@ -158,7 +158,7 @@ public class GUI extends JFrame implements Runnable, ActionListener {
updateGUI
(
xscale
,
yscale
);
updateGUI
(
xscale
,
yscale
);
//}
//}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/tec/letsgoing/ardublock/simulator/view/modules/Button.java
+
37
−
7
View file @
50b40ecc
...
@@ -26,7 +26,7 @@ import tec.letsgoing.ardublock.simulator.view.GUI;
...
@@ -26,7 +26,7 @@ import tec.letsgoing.ardublock.simulator.view.GUI;
*/
*/
public
class
Button
extends
Modul
implements
ActionListener
{
public
class
Button
extends
Modul
implements
ActionListener
{
private
int
[]
lastState
=
{
0
,
0
,
0
};
private
int
[]
lastState
=
{
0
,
0
,
0
};
private
ImageIcon
iconOff
,
iconOn
,
chipIcon
,
chipIcon_temp
;
private
ImageIcon
iconOff
,
iconOn
,
chipIcon
,
chipIcon_temp
,
iconOff_temp
,
iconOn_temp
;
private
JToggleButton
but1
,
but2
,
but3
;
private
JToggleButton
but1
,
but2
,
but3
;
private
JLabel
chiplabel
,
label1
,
label2
,
label3
;
private
JLabel
chiplabel
,
label1
,
label2
,
label3
;
private
int
xscale
=
GUI
.
getxscale
();
private
int
xscale
=
GUI
.
getxscale
();
...
@@ -36,21 +36,23 @@ public class Button extends Modul implements ActionListener {
...
@@ -36,21 +36,23 @@ public class Button extends Modul implements ActionListener {
chipIcon
=
_icon
;
chipIcon
=
_icon
;
iconOff
=
_icon1
;
iconOff
=
_icon1
;
iconOn
=
_icon2
;
iconOn
=
_icon2
;
iconOff_temp
=
iconOff
;
iconOn_temp
=
iconOn
;
chiplabel
=
new
JLabel
();
chiplabel
=
new
JLabel
();
but1
=
new
JToggleButton
();
but1
=
new
JToggleButton
();
but1
.
setIcon
(
iconOff
);
but1
.
setIcon
(
iconOff
_temp
);
but1
.
setActionCommand
(
"0"
);
but1
.
setActionCommand
(
"0"
);
but1
.
addActionListener
(
this
);
but1
.
addActionListener
(
this
);
but2
=
new
JToggleButton
();
but2
=
new
JToggleButton
();
but2
.
setIcon
(
iconOff
);
but2
.
setIcon
(
iconOff
_temp
);
but2
.
setActionCommand
(
"1"
);
but2
.
setActionCommand
(
"1"
);
but2
.
addActionListener
(
this
);
but2
.
addActionListener
(
this
);
but3
=
new
JToggleButton
();
but3
=
new
JToggleButton
();
but3
.
setIcon
(
iconOff
);
but3
.
setIcon
(
iconOff
_temp
);
but3
.
setActionCommand
(
"2"
);
but3
.
setActionCommand
(
"2"
);
but3
.
addActionListener
(
this
);
but3
.
addActionListener
(
this
);
...
@@ -79,13 +81,40 @@ public class Button extends Modul implements ActionListener {
...
@@ -79,13 +81,40 @@ public class Button extends Modul implements ActionListener {
chipIcon_temp
=
new
ImageIcon
(
chipIcon
.
getImage
().
getScaledInstance
(((
int
)(
0.3037
*
xscale
)),
((
int
)(
0.304
*
yscale
)),
Image
.
SCALE_SMOOTH
));
chipIcon_temp
=
new
ImageIcon
(
chipIcon
.
getImage
().
getScaledInstance
(((
int
)(
0.3037
*
xscale
)),
((
int
)(
0.304
*
yscale
)),
Image
.
SCALE_SMOOTH
));
chiplabel
.
setIcon
(
chipIcon_temp
);
chiplabel
.
setIcon
(
chipIcon_temp
);
chiplabel
.
setSize
(((
int
)(
0.3037
*
xscale
)),
((
int
)(
0.304
*
yscale
)));
chiplabel
.
setSize
(((
int
)(
0.3037
*
xscale
)),
((
int
)(
0.304
*
yscale
)));
layerpane
.
add
(
chiplabel
,
0
);
but1
.
setSize
(((
int
)(
0.0723
*
xscale
)),
((
int
)(
0.0724
*
yscale
)));
but1
.
setSize
(((
int
)(
0.0723
*
xscale
)),
((
int
)(
0.0724
*
yscale
)));
label1
.
setSize
(((
int
)(
0.0723
*
xscale
)),
((
int
)(
0.0724
*
yscale
)));
label1
.
setSize
(((
int
)(
0.0723
*
xscale
)),
((
int
)(
0.0724
*
yscale
)));
label1
.
setLocation
(((
int
)(
0.02996
*
xscale
)),
((
int
)(
0.06618
*
yscale
)));
label1
.
setLocation
(((
int
)(
0.02996
*
xscale
)),
((
int
)(
0.06618
*
yscale
)));
iconOff_temp
=
new
ImageIcon
(
iconOff
.
getImage
().
getScaledInstance
(((
int
)(
0.0723
*
xscale
)),
((
int
)(
0.0724
*
yscale
)),
Image
.
SCALE_SMOOTH
));
iconOn_temp
=
new
ImageIcon
(
iconOn
.
getImage
().
getScaledInstance
(((
int
)(
0.0723
*
xscale
)),
((
int
)(
0.0724
*
yscale
)),
Image
.
SCALE_SMOOTH
));
//Abfrage ob der jeweilige Button im moment gedrckt wurde oder nicht und dementsprechend wird das gas gezoomte icon gesetzt
if
(!
but1
.
isSelected
())
but1
.
setIcon
(
iconOff_temp
);
else
but1
.
setIcon
(
iconOn_temp
);
if
(!
but2
.
isSelected
())
but2
.
setIcon
(
iconOff_temp
);
else
but2
.
setIcon
(
iconOn_temp
);
if
(!
but3
.
isSelected
())
but3
.
setIcon
(
iconOff_temp
);
else
but3
.
setIcon
(
iconOn_temp
);
but2
.
setSize
(((
int
)(
0.0723
*
xscale
)),
((
int
)(
0.0724
*
yscale
)));
but2
.
setSize
(((
int
)(
0.0723
*
xscale
)),
((
int
)(
0.0724
*
yscale
)));
...
@@ -100,6 +129,7 @@ public class Button extends Modul implements ActionListener {
...
@@ -100,6 +129,7 @@ public class Button extends Modul implements ActionListener {
label1
.
add
(
but1
);
label1
.
add
(
but1
);
label2
.
add
(
but2
);
label2
.
add
(
but2
);
label3
.
add
(
but3
);
label3
.
add
(
but3
);
layerpane
.
add
(
chiplabel
,
0
);
layerpane
.
add
(
label1
,
0
);
layerpane
.
add
(
label1
,
0
);
layerpane
.
add
(
label2
,
0
);
layerpane
.
add
(
label2
,
0
);
layerpane
.
add
(
label3
,
0
);
layerpane
.
add
(
label3
,
0
);
...
@@ -141,9 +171,9 @@ public class Button extends Modul implements ActionListener {
...
@@ -141,9 +171,9 @@ public class Button extends Modul implements ActionListener {
Integer
pin
=
Integer
.
parseInt
(
arg0
.
getActionCommand
());
Integer
pin
=
Integer
.
parseInt
(
arg0
.
getActionCommand
());
boolean
bool
=
((
JToggleButton
)
arg0
.
getSource
()).
isSelected
();
boolean
bool
=
((
JToggleButton
)
arg0
.
getSource
()).
isSelected
();
if
(
bool
)
{
if
(
bool
)
{
((
JToggleButton
)
arg0
.
getSource
()).
setIcon
(
iconOn
);
((
JToggleButton
)
arg0
.
getSource
()).
setIcon
(
iconOn
_temp
);
}
else
{
}
else
{
((
JToggleButton
)
arg0
.
getSource
()).
setIcon
(
iconOff
);
((
JToggleButton
)
arg0
.
getSource
()).
setIcon
(
iconOff
_temp
);
}
}
int
value
=
0
;
int
value
=
0
;
...
...
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