aboutsummaryrefslogtreecommitdiff
path: root/robottino/all_versions/v4.0/src/Robot.java
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2026-03-26 19:27:18 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2026-03-26 19:27:18 +0100
commit7167b4341ef290d56fb96e2af10883a4b925d83b (patch)
tree1eb1b9e5ab82ddd89540e68d6b22ae69514575c6 /robottino/all_versions/v4.0/src/Robot.java
downloadancient-projects-7167b4341ef290d56fb96e2af10883a4b925d83b.tar.gz
ancient-projects-7167b4341ef290d56fb96e2af10883a4b925d83b.zip
I found my old code!HEADmaster
Diffstat (limited to 'robottino/all_versions/v4.0/src/Robot.java')
-rwxr-xr-xrobottino/all_versions/v4.0/src/Robot.java126
1 files changed, 126 insertions, 0 deletions
diff --git a/robottino/all_versions/v4.0/src/Robot.java b/robottino/all_versions/v4.0/src/Robot.java
new file mode 100755
index 0000000..bf0e186
--- /dev/null
+++ b/robottino/all_versions/v4.0/src/Robot.java
@@ -0,0 +1,126 @@
1/*
2Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org>
3
4This file is part of Robottino.
5
6 Robottino is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 Robottino is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Robottino; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
20*/
21
22import javax.swing.*;
23import java.awt.event.*;
24import java.awt.*;
25
26public class Robot {
27 public static Main main = new Main();
28 boolean leftArm, rightArm, leftLeg, rightLeg;
29 String nomeRobot;
30 Robot precedenteRobot, prossimoRobot;
31 RobotFrame robotFrame;
32 Robot() {
33 this( false, false, false, false, "", main.list.ultimoRobot, null );
34 }
35 Robot( String nome ) {
36 this ( false, false, false, false, nome, main.list.ultimoRobot, null );
37 }
38 Robot( boolean la, boolean ra, boolean ll, boolean rl, String nome, Robot prec, Robot prox ) {
39 leftArm = la;
40 rightArm = ra;
41 leftLeg = ll;
42 rightLeg = rl;
43 nomeRobot = nome;
44 precedenteRobot = prec;
45 prossimoRobot = prox;
46 robotFrame = new RobotFrame( nome );
47 robotFrame.setSize( 350, 550 );
48 robotFrame.setVisible( true );
49 robotFrame.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE );
50 robotFrame.addWindowListener(
51 new WindowAdapter() {
52 public void windowClosing( WindowEvent e ) {
53 int selezione = JOptionPane.showOptionDialog( Robot.this.robotFrame, "Eliminare il robottino " + Robot.this.getName() + " ?", "Robottino v4.0 - Cancellazione robottino", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { "Si", "No" }, "No" );
54 if ( selezione == JOptionPane.YES_OPTION ) {
55 main.list.deleteRobot( Robot.this.getName() );
56 robotFrame.dispose();
57 }
58 else {
59 try {
60 Thread.currentThread().sleep( 50 );
61 } catch ( Exception e2 ) {}
62 robotFrame.repaint();
63 }
64 }
65 public void windowActivated( WindowEvent e ) {
66 robotFrame.repaint();
67 }
68 }
69 );
70 robotFrame.addComponentListener(
71 new ComponentAdapter() {
72 public void componentMoved( ComponentEvent e ) {
73 try {
74 Thread.currentThread().sleep( 50 );
75 } catch ( Exception e2 ) {}
76 robotFrame.repaint();
77 }
78 public void componentResized( ComponentEvent e ) {
79 try {
80 Thread.currentThread().sleep( 50 );
81 } catch ( Exception e2 ) {}
82 robotFrame.repaint();
83 }
84 }
85 );
86 }
87 void setLA( boolean la ) {
88 setPositions( la, this.rightArm, this.leftLeg, this.rightLeg );
89 }
90 void setRA( boolean ra ) {
91 setPositions( this.leftArm, ra, this.leftLeg, this.rightLeg );
92 }
93 void setLL( boolean ll ) {
94 setPositions( this.leftArm, this.rightArm, ll, this.rightLeg );
95 }
96 void setRL( boolean rl ) {
97 setPositions( this.leftArm, this.rightArm, this.leftLeg, rl );
98 }
99 void setPositions( boolean la, boolean ra, boolean ll, boolean rl ) {
100 leftArm = la;
101 rightArm = ra;
102 leftLeg = ll;
103 rightLeg = rl;
104 }
105 void setName( String nome ) {
106 nomeRobot = nome;
107 }
108 boolean getLA() {
109 return leftArm;
110 }
111 boolean getRA() {
112 return rightArm;
113 }
114 boolean getLL() {
115 return leftLeg;
116 }
117 boolean getRL() {
118 return rightLeg;
119 }
120 String getName() {
121 return nomeRobot;
122 }
123 Robot getNext() {
124 return prossimoRobot;
125 }
126} \ No newline at end of file

Generated with cgit - Back to sebastiano.tronto.net