RobotPanel.java (3134B)
1 /* 2 Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org> 3 4 This 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 22 import javax.swing.*; 23 import java.awt.*; 24 25 public class RobotPanel extends JPanel { 26 public static String nomeRobot; 27 public static Main main; 28 public static ImageIcon ra, la, rl, ll, body; 29 public static int rax, ray, lax, lay, rlx, rly, llx, lly; 30 RobotPanel( String nomeRobot ) { 31 this.nomeRobot = nomeRobot; 32 rax = 66; 33 ray = 248; 34 lax = 225; 35 lay = 242; 36 rlx = 84; 37 rly = 367; 38 llx = 148; 39 lly = 367; 40 body = new ImageIcon( ClassLoader.getSystemResource( "img/robot.gif" ) ); 41 ra = new ImageIcon( ClassLoader.getSystemResource( "img/raoff.gif" ) ); 42 la = new ImageIcon( ClassLoader.getSystemResource( "img/laoff.gif" ) ); 43 rl = new ImageIcon( ClassLoader.getSystemResource( "img/rloff.gif" ) ); 44 ll = new ImageIcon( ClassLoader.getSystemResource( "img/lloff.gif" ) ); 45 } 46 public void paint ( Graphics g ) { 47 super.paint( g ); 48 body.paintIcon( this, g, 100, 60 ); 49 ra.paintIcon( this, g, this.rax, this.ray ); 50 la.paintIcon( this, g, this.lax, this.lay ); 51 rl.paintIcon( this, g, this.rlx, this.rly ); 52 ll.paintIcon( this, g, this.llx, this.lly ); 53 } 54 public void setImages() { 55 if ( main.list.getRobot( nomeRobot ).rightArm ) { 56 this.ra = new ImageIcon( ClassLoader.getSystemResource( "img/raon.gif" ) ); 57 this.rax = 68; 58 this.ray = 128; 59 } 60 else { 61 this.ra = new ImageIcon( ClassLoader.getSystemResource( "img/raoff.gif" ) ); 62 this.rax = 66; 63 this.ray = 248; 64 } 65 if ( main.list.getRobot( nomeRobot ).leftArm ) { 66 this.la = new ImageIcon( ClassLoader.getSystemResource( "img/laon.gif" ) ); 67 this.lax = 224; 68 this.lay = 118; 69 } 70 else { 71 this.la = new ImageIcon( ClassLoader.getSystemResource( "img/laoff.gif" ) ); 72 this.lax = 225; 73 this.lay = 242; 74 } 75 if ( main.list.getRobot( nomeRobot ).rightLeg ) { 76 this.rl = new ImageIcon( ClassLoader.getSystemResource( "img/rlon.gif" ) ); 77 this.rlx = 84; 78 this.rly = 356; 79 } 80 else { 81 this.rl = new ImageIcon( ClassLoader.getSystemResource( "img/rloff.gif" ) ); 82 this.rlx = 84; 83 this.rly = 367; 84 } 85 if ( main.list.getRobot( nomeRobot ).leftLeg ) { 86 this.ll = new ImageIcon( ClassLoader.getSystemResource( "img/llon.gif" ) ); 87 this.llx = 140; 88 this.lly = 363; 89 } 90 else { 91 this.ll = new ImageIcon( ClassLoader.getSystemResource( "img/lloff.gif" ) ); 92 this.llx = 148; 93 this.lly = 367; 94 } 95 } 96 }