Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Basic Question Need Help

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Basic Question Need Help

    The method tileToScreen(Tile, int) is undefined for the type Calculations

    Point M = Calculations.tileToScreen(Enemy.getLocation(), Enemy.getHeight());

    I changed it tiles to screen to
    Point M = Calculations.isOnScreen(Enemy.getLocation(), Enemy.getHeight());

    The method isOnScreen(int, int) in the type Calculations is not applicable for the arguments (Tile, int)


    How can i fix this? This is the only Error in my Script and i have no idea how to fix it please help


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Basic Question Need Help

    Without seeing more code hard to say for sure. I can't tell exactly what it is you are trying to do.

    Are you trying to use the method Calculations.tileToScreen() or Calculations.isOnScreen()?
    Which ever one it is you are trying to use, what is the signature of the method?
    methodName(int, int)? or methodName(Tile, int)? (or possibly something else?)

    How ever the above works out... What does Enemy.getLocation() return? What does Enemy.getHeight() return? ....Do the types of these match the type of the method you are trying to use?

  3. #3
    Junior Member
    Join Date
    Jul 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Basic Question Need Help

    Heres my full onReprint code where the issue is.

    public void onRepaint(Graphics grphcs) {
        	drawMouse(grphcs);
    		strExp = Skills.getExperience(Skills.STRENGTH) - SstrExp;
    		attExp = Skills.getExperience(Skills.ATTACK) - SattExp;
    		defExp = Skills.getExperience(Skills.DEFENSE) - SdefExp;
    		hpExp = Skills.getExperience(Skills.CONSTITUTION) - ShpExp;
    		runtime = System.currentTimeMillis() - starttime;
    		strExph = (int) ExpHour(strExp);
    		attExph = (int) ExpHour(attExp);
    		defExph = (int) ExpHour(defExp);
    		hpExph = (int) ExpHour(hpExp);
    		Graphics2D g = (Graphics2D) grphcs;
    		g.setRenderingHints(antialiasing);
    		g.setFont(font1);
    		g.setColor(color3);
    		g.drawString("Attack xp/h :" + attExph + " (" + attExp + ")", 555, 310);
    		g.drawString("Strenght xp/h :" + strExph + " (" + strExp + ")", 556,
    				332);
    		g.drawString("Defence xp/h :" + defExph + " (" + defExp + ")", 555, 354);
    		g.drawString("Hitpoints xp/h :" + hpExph + " (" + hpExp + ")", 556, 376);
    		g.drawString("Time Running :" + formatTime(runtime), 557, 280);
    		g.drawString("Status: " + status, 555, 507);
    		g.drawString("Version " + version, 555, 407);
            if (Game.isLoggedIn()) {
            	int CurrX=Mouse.getLocation().x;
    			int CurrY=Mouse.getLocation().y;
     
    			g.setFont(new Font("Arial", 0, 12));
    			g.setColor(new Color(255, 100, 100, 150));
     
    			if (UseSpecialAttack == true) {
    				g.drawImage(SpecialAttackBg, 526, 124, null);
    				SpecTimerSec = SpecTimer / 10;
    				Height = -2 + ((SpecCurr/3) + 3 - (SpecTimerSec / 10));
    				Y = 158 - Height;
    				g.fillRect(526,Y,34,Height);
    			}
     
    			if (UseSpecialAttack == true) {
     
    				g.drawImage(SpecialAttack,526,124,null);
    				g.setFont(new Font("Arial", 0, 16));
     
    				if (SpecCurr > 90) {
    					g.setColor(new Color(0, 0, 0));
    					g.drawString("" + SpecCurr, 529, 144);
    					g.setColor(new Color(255, 255, 255));
    					g.drawString("" + SpecCurr, 528, 143);
    				} else {
    					g.setColor(new Color(0, 0, 0));
    					g.drawString(""+SpecCurr,535,144);
    					g.setColor(new Color(255,255,255));
    					g.drawString(""+SpecCurr,534,143);
    				}
     
    				if (SpecCurr < 99) {
    					g.setFont(new Font("Arial", 0, 12));
    					g.setColor(new Color(0, 0, 0));
    					g.drawString(""+SpecTimerSec,539,155);
    					g.setColor(new Color(255,255,255));
    					g.drawString(""+SpecTimerSec,538,154);
    				}
     
    			}
     
    			if (UseVengeance == true) {
    				g.drawImage(VenganceBg,690,127,null);
    				Height = 30 - VengTimer / 10;
    				Y = 157 - Height;
    				g.setColor(new Color(255, 255, 255, 150));
    				g.fillRect(690,Y,30,Height);
    				g.setFont(new Font("Arial", 0, 12));
    				g.drawImage(Vengance,690,127,null);
    				VengTimerSec = VengTimer / 10;
    				g.setFont(new Font("Arial", 0, 12));
    				g.setColor(new Color(0, 0, 0));
    				g.drawString(""+VengTimerSec,728,153);
    				int Red = VengTimer;
    				int Green = 300 - VengTimer;
    				if ( Red > 254 ) {
    					Red = 254;
    				}
    				if ( Red < 1 ) {
    					Red = 0;
    				}
    				if ( Green > 254 ) {
    					Green = 254;
    				}
    				if ( Green < 1 ) {
    					Green = 0;
    				}
    				g.setColor(new Color(Red, Green, 0));
    				g.drawString(""+VengTimerSec, 727, 152);
    				g.drawImage(VengPic, 700, 134, null);
    				if (VengTimerSec > 0) {
    					g.drawImage(VengPicNotReady, 700, 134, null);
    				}
    			}
     
    			if (FreezeTimer > 0 || OptionMenuOpen == true) {
    				if (UseFreeze == true) {
    					g.drawImage(BarragePicture, FreezeX, FreezeY, null);
    					g.setFont(new Font("Arial", 0, 24));
    					g.setColor(new Color(0, 0, 50));
    					g.drawString("" + (FreezeTimer / 10), FreezeX + 30, FreezeY + 71);
    				}
    			}
     
    			{
    				g.drawImage(Options, 611, 297, null);
    			}
     
    			{
    				OptionMenuOpen = true;
    			}
     
    			if (Mouse.isPressed() && CurrX > 216 && CurrX < 316 && CurrY > 433 && CurrY < 465) {
    				OptionMenuOpen = false;
    			}
     
    			if (OptionMenuOpen == true) {
     
    				g.drawImage(OptionsBackground, 0, 338, null);
    				g.drawImage(Confirm, 217, 435, null);
     
    				if (!Mouse.isPressed()) {
    					Clicked = false;
    					MoveHitPredictor = false;
    					MoveStatGrabber = false;
    					MoveFreeze = false;
    				}
     
    				//======= HitPredictor, Move and Toggle. =======
    				if (UseHitPredictor == true) {
    					g.drawImage(OnButton, 287, 352, null);
    				} else {
    					g.drawImage(OffButton, 287, 352, null);
    				}
    				if (UseHitPredictor == false && Clicked == false && Mouse.isPressed() && CurrX > 287 && CurrX < 358 && CurrY > 352 && CurrY < 372) {
    					UseHitPredictor = true;
    					Clicked = true;
    				}
    				if (UseHitPredictor == true && Clicked == false && Mouse.isPressed() && CurrX > 287 && CurrX < 358 && CurrY > 352 && CurrY < 372) {
    					UseHitPredictor = false;
    					Clicked = true;
    				}
    				if (UseHitPredictor == true && MoveStatGrabber == false && MoveFreeze == false && Mouse.isPressed() && CurrX > HitPredX && CurrX < HitPredX + 88 && CurrY > HitPredY && CurrY < HitPredY + 29) {
    					MoveHitPredictor = true;
    				}
    				if (MoveHitPredictor == true) {
    					HitPredX = CurrX - 44;
    					HitPredY = CurrY - 14;
    				}
     
    				//======= StatGrabber, Move and Toggle. =======
    				if (UseStatGrabber == true) {
    					g.drawImage(OnButton,287, 382, null);
    				} else {
    					g.drawImage(OffButton, 287, 382, null);
    				}
    				if (UseStatGrabber == false && Clicked == false && Mouse.isPressed() && CurrX > 287 && CurrX < 358 && CurrY > 382 && CurrY < 402) {
    					UseStatGrabber = true;
    					Clicked = true;
    				}
    				if (UseStatGrabber == true && Clicked == false && Mouse.isPressed() && CurrX > 287 && CurrX < 358 && CurrY > 382 && CurrY < 402) {
    					UseStatGrabber = false;
    					Clicked = true;
    				}
    				if (UseStatGrabber == true && MoveHitPredictor == false && MoveFreeze == false && Mouse.isPressed() && CurrX > StatGrabberX + 80 && CurrX < StatGrabberX + 550 && CurrY > StatGrabberY && CurrY < StatGrabberY + 29) {
    					MoveStatGrabber = true;
    				}
    				if (MoveStatGrabber == true) {
    					StatGrabberX = CurrX - 275;
    					StatGrabberY = CurrY - 14;
    				}
     
    				//======= HpAboveHead, Toggle. =======
    				if (UseHpAboveHead == true) {
    					g.drawImage(OnButton, 287, 410, null);
    				} else {
    					g.drawImage(OffButton, 287, 410, null);
    				}
    				if (UseHpAboveHead == false && Clicked == false && Mouse.isPressed() && CurrX > 287 && CurrX < 358 && CurrY > 410 && CurrY < 430) {
    					UseHpAboveHead = true;
    					Clicked = true;
    				}
    				if (UseHpAboveHead == true && Clicked == false && Mouse.isPressed() && CurrX > 287 && CurrX < 358 && CurrY > 410 && CurrY < 430) {
    					UseHpAboveHead = false;
    					Clicked = true;
    				}
     
    				//======= Freeze Timer - NOT ADDED YET! =======
    				if (UseFreeze == true) {
    					g.drawImage(OnButton, 179, 352, null);
    				} else {
    					g.drawImage(OffButton, 179, 352, null);
    				}
    				if (UseFreeze == false && Clicked == false && Mouse.isPressed() && CurrX > 179 && CurrX < 250 && CurrY > 352 && CurrY < 372) {
    					UseFreeze = true;
    					Clicked = true;
    				}
    				if (UseFreeze == true && Clicked == false && Mouse.isPressed() && CurrX > 179 && CurrX < 250 && CurrY > 352 && CurrY < 372) {
    					UseFreeze = false;
    					Clicked = true;
    				} 
    				if (UseFreeze == true && MoveHitPredictor == false && MoveStatGrabber == false && Mouse.isPressed() && CurrX > FreezeX && CurrX < FreezeX + 81 && CurrY > FreezeY && CurrY < FreezeX + 117) {
    					MoveFreeze = true;
    				}
    				if (MoveFreeze == true) {
    					FreezeX = CurrX - 41;
    					FreezeY = CurrY - 60;
    				}
     
    				//======= VenganceTimer, Toggle. =======
    				if (UseVengeance == true) {
    					g.drawImage(OnButton, 179, 382, null);
    				} else {
    					g.drawImage(OffButton, 179, 382, null);
    				}
    				if (UseVengeance == false && Clicked == false && Mouse.isPressed() && CurrX > 179 && CurrX < 250 && CurrY > 382 && CurrY < 402) {
    					UseVengeance = true;
    					Clicked = true;
    				}
    				if (UseVengeance == true && Clicked == false && Mouse.isPressed() && CurrX > 179 && CurrX < 250 && CurrY > 382 && CurrY < 402) {
    					UseVengeance = false;
    					Clicked = true;
    				}
     
    				//======= SpecialAttackTimer, Toggle. =======
    				if (UseSpecialAttack == true) {
    					g.drawImage(OnButton, 179, 410, null);
    				} else {
    					g.drawImage(OffButton, 179, 410, null);
    				}
    				if (UseSpecialAttack == false && Clicked == false && Mouse.isPressed() && CurrX > 179 && CurrX < 250 && CurrY > 410 && CurrY < 430) {
    					UseSpecialAttack = true;
    					Clicked = true;
    				}
    				if (UseSpecialAttack == true && Clicked == false && Mouse.isPressed() && CurrX > 179 && CurrX < 250 && CurrY > 410 && CurrY < 430) {
    					UseSpecialAttack = false;
    					Clicked = true;
    				}
     
    			}
     
    			g.setFont(new Font("Arial", 0, 20));
     
    			if (Enemy != null ) {
     
    				Enemy.getLocation(); Enemy.getHeight();
     
    				Point M = Calculations.isOnScreen((Enemy.getLocation()));
    				if (Calculations.isOnScreen(M) && UseHpAboveHead == true) {
     
        					Character interacting = Players.getLocal().getInteracting();
     
    					if(interacting instanceof RSNPC){
     
    						g.setColor(new Color(0, 0, 0));
    						g.drawString("Hp: " + EnemyFinalHp + "%", M.x - 35, M.y - 35);
    						if (EnemyFinalHp > 50) {
    							g.setColor(new Color(0, 255, 0));
    						}
    						if (EnemyFinalHp < 51) {
    							g.setColor(new Color(255, 0, 0));
    						}
    						g.drawString("Hp: " + EnemyFinalHp + "%", M.x - 35, M.y - 35);
     
    					} else {
    						if (EnemyFinalHp > 100) {
    							g.setColor(new Color(0, 0, 0));
    							g.drawString("Hp: " + EnemyFinalHp + " / " + EnemyHp, M.x - 50, M.y - 40);
    								if (EnemyFinalHp / EnemyHp * 100 > 50) {
    								g.setColor(new Color(0, 255, 0));
    							}
    							if (EnemyFinalHp / EnemyHp * 100  < 51) {
    								g.setColor(new Color(255, 0, 0));
    								}
    							g.drawString("Hp: " + EnemyFinalHp + " / " + EnemyHp, M.x - 50, M.y - 40);
    						}
     
    						if (EnemyHp == 10) {
    							g.setColor(new Color(0, 0, 0));
    							g.drawString("Hp: " + EnemyFinalHp + "%", M.x - 35, M.y - 40);
    							if (EnemyFinalHp > 50) {
    								g.setColor(new Color(0, 255, 0));
    							}
    							if (EnemyFinalHp < 51) {
    								g.setColor(new Color(255, 0, 0));
    							}
    							g.drawString("Hp: " + EnemyFinalHp + "%", M.x - 35, M.y - 40);
    						}
    					}
    				}
     
    			}
     
    			g.setFont(new Font("Arial", 0, 15));
     
    			g.drawImage(Report, 404, 481, null);
    			g.setColor(new Color(255, 255, 255));
    			g.drawString(""+ EnemyName , 411, 497);
     
    			if (UseHitPredictor == true) {
     
    				g.drawImage(HitPredictor, HitPredX, HitPredY, null);
     
    				if (DisplayFor > 0 && Display < 2000) {
    					if (hit > 1000) {
    						hitS = "";
    					} else {
    						hitS = Integer.toString((int) hit);
    						g.setFont(new Font("Arial", 0, 25));
    						g.setColor(new Color(0, 0, 0, DisplayFor*12));
    						g.drawString("" + hitS, HitPredX + 14, HitPredY + 24);
    						g.setColor(new Color(255, 0, 0, DisplayFor*12));
    						g.drawString("" + hitS, HitPredX + 13, HitPredY + 23);
    					}
    				}
     
    			}
     
    			if (!(UseStatGrabber == false)) {
     
    				g.drawImage(StatGrabber, StatGrabberX + 88, StatGrabberY, null);
     
    				g.setFont(new Font("Arial", 0, 12));
     
    				g.setColor(new Color(0, 0, 0));
    				g.drawString("" + MyAtt, StatGrabberX + 122, StatGrabberY + 13);
    				Compare(MyAtt, EnemyAtt);
    				g.setColor(C);
    				g.drawString("" + MyAtt, StatGrabberX+121, StatGrabberY + 12);
     
    				if (EnemyAtt !=1) {
    					g.setColor(new Color(0, 0, 0));
    					g.drawString("" + EnemyAtt, StatGrabberX + 133, StatGrabberY + 26);
    					Compare(EnemyAtt,MyAtt);
    					g.setColor(C);
    					g.drawString(""+EnemyAtt, StatGrabberX + 132, StatGrabberY + 25);
    				}
     
    				g.setColor(new Color(0, 0, 0));
    				g.drawString("" + MyStr, StatGrabberX + 183, StatGrabberY + 13);
    				Compare(MyStr, EnemyStr);
    				g.setColor(C);
    				g.drawString("" + MyStr, StatGrabberX + 182, StatGrabberY + 12);
     
    				if (EnemyStr !=1) {
    					g.setColor(new Color(0, 0, 0));
    					g.drawString("" + EnemyStr, StatGrabberX + 193, StatGrabberY + 26);
    					Compare(EnemyStr,MyStr);
    					g.setColor(C);
    					g.drawString("" + EnemyStr, StatGrabberX + 192, StatGrabberY + 25);
    				}
     
    				g.setColor(new Color(0, 0, 0));
    				g.drawString("" + MyDef, StatGrabberX + 243, StatGrabberY + 13);
    				Compare(MyDef, EnemyDef);
    				g.setColor(C);
    				g.drawString("" + MyDef, StatGrabberX + 242, StatGrabberY +12);
     
    				if (EnemyDef !=1) {
    					g.setColor(new Color(0, 0, 0));
    					g.drawString("" + EnemyDef, StatGrabberX + 252, StatGrabberY + 26);
    					Compare(EnemyDef, MyDef);
    					g.setColor(C);
    					g.drawString("" + EnemyDef, StatGrabberX + 251, StatGrabberY + 25);
    				}
     
    				g.setColor(new Color(0, 0, 0));
    				g.drawString("" + MyHp, StatGrabberX + 298, StatGrabberY + 13);
    				Compare(MyHp, EnemyHp);
    				g.setColor(C);
    				g.drawString("" + MyHp, StatGrabberX + 297, StatGrabberY + 12);
     
    				if (EnemyHp > 10) {
    					g.setColor(new Color(0, 0, 0));
    					g.drawString("" + EnemyHp, StatGrabberX + 308, StatGrabberY + 26);
    					Compare(EnemyHp, MyHp);
    					g.setColor(C);
    					g.drawString("" + EnemyHp, StatGrabberX+307, StatGrabberY + 25);
    				}
     
    				g.setColor(new Color(0, 0, 0));
    				g.drawString("" + MyMagic, StatGrabberX + 363, StatGrabberY + 13);
    				Compare(MyMagic, EnemyMagic);
    				g.setColor(C);
    				g.drawString("" + MyMagic, StatGrabberX + 362, StatGrabberY + 12);
     
    				if (EnemyMagic !=1) {
    					g.setColor(new Color(0, 0, 0));
    					g.drawString("" + EnemyMagic, StatGrabberX + 373, StatGrabberY + 26);
    					Compare(EnemyMagic, MyMagic);
    					g.setColor(C);
    					g.drawString("" + EnemyMagic, StatGrabberX + 372, StatGrabberY + 25);
    				}
     
    				g.setColor(new Color(0, 0, 0));
    				g.drawString("" + MyRange, StatGrabberX + 423, StatGrabberY + 13);
    				Compare(MyRange, EnemyRange);
    				g.setColor(C);
    				g.drawString("" + MyRange, StatGrabberX + 422, StatGrabberY + 12);
     
    				if (EnemyRange !=1) {
    					g.setColor(new Color(0, 0, 0));
    					g.drawString("" + EnemyRange, StatGrabberX + 433, StatGrabberY + 26);
    					Compare(EnemyRange, MyRange);
    					g.setColor(C);
    					g.drawString("" + EnemyRange, StatGrabberX + 432, StatGrabberY + 25);
    				}
     
    				g.setColor(new Color(0, 0, 0));
    				g.drawString("" + MyPrayer, StatGrabberX + 483,StatGrabberY + 13);
    				Compare(MyPrayer, EnemyPrayer);
    				g.setColor(C);
    				g.drawString("" + MyPrayer, StatGrabberX + 482, StatGrabberY + 12);
     
    				if (EnemyPrayer !=1) {
    					g.setColor(new Color(0, 0, 0));
    					g.drawString("" + EnemyPrayer, StatGrabberX + 493, StatGrabberY + 26);
    					Compare(EnemyPrayer, MyPrayer);
    					g.setColor(C);
    					g.drawString("" + EnemyPrayer, StatGrabberX + 492, StatGrabberY + 25);
    					Graphics2D g1 = (Graphics2D) grphcs;
    		            g1.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING,
    		                    RenderingHints.VALUE_ANTIALIAS_ON));
     
    		            Player botter = Players.getLocal();
    		            if ((players != null)
    		                    && (inWilderness())) {
    		                for (Player p : players) {
    		                    if ((p != null) && (!p.equals(botter))) {
    		                        if (GUI_SETTINGS.TILE.enabled() && p.getLocation().isOnScreen()) {
    		                            drawTile(g1, p.getLocation(), colorForLevel(p));
    		                        }
    		                        if (GUI_SETTINGS.BOUNDING_BOX.enabled() && p.isOnScreen()) {
    		                            drawPlayer(g1, p, colorForLevel(p));
    		                        }
    		                        if (GUI_SETTINGS.NAME_LEVEL.enabled() && p.isOnScreen()) {
    		                            drawPlayerInformation(g1, p, colorForLevel(p));
    		                        }
    				}
    			}
    		}
    	}
                        }
                    }
                }

  4. #4
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Basic Question Need Help

    Let me try to reformat your code for readability:

     
       public void onRepaint(Graphics grphcs) {
          drawMouse(grphcs);
          strExp = Skills.getExperience(Skills.STRENGTH) - SstrExp;
          attExp = Skills.getExperience(Skills.ATTACK) - SattExp;
          defExp = Skills.getExperience(Skills.DEFENSE) - SdefExp;
          hpExp = Skills.getExperience(Skills.CONSTITUTION) - ShpExp;
          runtime = System.currentTimeMillis() - starttime;
          strExph = (int) ExpHour(strExp);
          attExph = (int) ExpHour(attExp);
          defExph = (int) ExpHour(defExp);
          hpExph = (int) ExpHour(hpExp);
          Graphics2D g = (Graphics2D) grphcs;
          g.setRenderingHints(antialiasing);
          g.setFont(font1);
          g.setColor(color3);
          g.drawString("Attack xp/h :" + attExph + " (" + attExp + ")", 555, 310);
          g.drawString("Strenght xp/h :" + strExph + " (" + strExp + ")", 556, 332);
          g.drawString("Defence xp/h :" + defExph + " (" + defExp + ")", 555, 354);
          g.drawString("Hitpoints xp/h :" + hpExph + " (" + hpExp + ")", 556, 376);
          g.drawString("Time Running :" + formatTime(runtime), 557, 280);
          g.drawString("Status: " + status, 555, 507);
          g.drawString("Version " + version, 555, 407);
          if (Game.isLoggedIn()) {
             int CurrX = Mouse.getLocation().x;
             int CurrY = Mouse.getLocation().y;
     
             g.setFont(new Font("Arial", 0, 12));
             g.setColor(new Color(255, 100, 100, 150));
     
             if (UseSpecialAttack == true) {
                g.drawImage(SpecialAttackBg, 526, 124, null);
                SpecTimerSec = SpecTimer / 10;
                Height = -2 + ((SpecCurr / 3) + 3 - (SpecTimerSec / 10));
                Y = 158 - Height;
                g.fillRect(526, Y, 34, Height);
             }
     
             if (UseSpecialAttack == true) {
     
                g.drawImage(SpecialAttack, 526, 124, null);
                g.setFont(new Font("Arial", 0, 16));
     
                if (SpecCurr > 90) {
                   g.setColor(new Color(0, 0, 0));
                   g.drawString("" + SpecCurr, 529, 144);
                   g.setColor(new Color(255, 255, 255));
                   g.drawString("" + SpecCurr, 528, 143);
                } else {
                   g.setColor(new Color(0, 0, 0));
                   g.drawString("" + SpecCurr, 535, 144);
                   g.setColor(new Color(255, 255, 255));
                   g.drawString("" + SpecCurr, 534, 143);
                }
     
                if (SpecCurr < 99) {
                   g.setFont(new Font("Arial", 0, 12));
                   g.setColor(new Color(0, 0, 0));
                   g.drawString("" + SpecTimerSec, 539, 155);
                   g.setColor(new Color(255, 255, 255));
                   g.drawString("" + SpecTimerSec, 538, 154);
                }
     
             }
     
             if (UseVengeance == true) {
                g.drawImage(VenganceBg, 690, 127, null);
                Height = 30 - VengTimer / 10;
                Y = 157 - Height;
                g.setColor(new Color(255, 255, 255, 150));
                g.fillRect(690, Y, 30, Height);
                g.setFont(new Font("Arial", 0, 12));
                g.drawImage(Vengance, 690, 127, null);
                VengTimerSec = VengTimer / 10;
                g.setFont(new Font("Arial", 0, 12));
                g.setColor(new Color(0, 0, 0));
                g.drawString("" + VengTimerSec, 728, 153);
                int Red = VengTimer;
                int Green = 300 - VengTimer;
                if (Red > 254) {
                   Red = 254;
                }
                if (Red < 1) {
                   Red = 0;
                }
                if (Green > 254) {
                   Green = 254;
                }
                if (Green < 1) {
                   Green = 0;
                }
                g.setColor(new Color(Red, Green, 0));
                g.drawString("" + VengTimerSec, 727, 152);
                g.drawImage(VengPic, 700, 134, null);
                if (VengTimerSec > 0) {
                   g.drawImage(VengPicNotReady, 700, 134, null);
                }
             }
     
             if (FreezeTimer > 0 || OptionMenuOpen == true) {
                if (UseFreeze == true) {
                   g.drawImage(BarragePicture, FreezeX, FreezeY, null);
                   g.setFont(new Font("Arial", 0, 24));
                   g.setColor(new Color(0, 0, 50));
                   g.drawString("" + (FreezeTimer / 10), FreezeX + 30, FreezeY + 71);
                }
             }
     
             {
                g.drawImage(Options, 611, 297, null);
             }
     
             {
                OptionMenuOpen = true;
             }
     
             if (Mouse.isPressed() && CurrX > 216 && CurrX < 316 && CurrY > 433
                   && CurrY < 465) {
                OptionMenuOpen = false;
             }
     
             if (OptionMenuOpen == true) {
     
                g.drawImage(OptionsBackground, 0, 338, null);
                g.drawImage(Confirm, 217, 435, null);
     
                if (!Mouse.isPressed()) {
                   Clicked = false;
                   MoveHitPredictor = false;
                   MoveStatGrabber = false;
                   MoveFreeze = false;
                }
     
                // ======= HitPredictor, Move and Toggle. =======
                if (UseHitPredictor == true) {
                   g.drawImage(OnButton, 287, 352, null);
                } else {
                   g.drawImage(OffButton, 287, 352, null);
                }
                if (UseHitPredictor == false && Clicked == false
                      && Mouse.isPressed() && CurrX > 287 && CurrX < 358
                      && CurrY > 352 && CurrY < 372) {
                   UseHitPredictor = true;
                   Clicked = true;
                }
                if (UseHitPredictor == true && Clicked == false
                      && Mouse.isPressed() && CurrX > 287 && CurrX < 358
                      && CurrY > 352 && CurrY < 372) {
                   UseHitPredictor = false;
                   Clicked = true;
                }
                if (UseHitPredictor == true && MoveStatGrabber == false
                      && MoveFreeze == false && Mouse.isPressed()
                      && CurrX > HitPredX && CurrX < HitPredX + 88
                      && CurrY > HitPredY && CurrY < HitPredY + 29) {
                   MoveHitPredictor = true;
                }
                if (MoveHitPredictor == true) {
                   HitPredX = CurrX - 44;
                   HitPredY = CurrY - 14;
                }
     
                // ======= StatGrabber, Move and Toggle. =======
                if (UseStatGrabber == true) {
                   g.drawImage(OnButton, 287, 382, null);
                } else {
                   g.drawImage(OffButton, 287, 382, null);
                }
                if (UseStatGrabber == false && Clicked == false
                      && Mouse.isPressed() && CurrX > 287 && CurrX < 358
                      && CurrY > 382 && CurrY < 402) {
                   UseStatGrabber = true;
                   Clicked = true;
                }
                if (UseStatGrabber == true && Clicked == false && Mouse.isPressed()
                      && CurrX > 287 && CurrX < 358 && CurrY > 382 && CurrY < 402) {
                   UseStatGrabber = false;
                   Clicked = true;
                }
                if (UseStatGrabber == true && MoveHitPredictor == false
                      && MoveFreeze == false && Mouse.isPressed()
                      && CurrX > StatGrabberX + 80 && CurrX < StatGrabberX + 550
                      && CurrY > StatGrabberY && CurrY < StatGrabberY + 29) {
                   MoveStatGrabber = true;
                }
                if (MoveStatGrabber == true) {
                   StatGrabberX = CurrX - 275;
                   StatGrabberY = CurrY - 14;
                }
     
                // ======= HpAboveHead, Toggle. =======
                if (UseHpAboveHead == true) {
                   g.drawImage(OnButton, 287, 410, null);
                } else {
                   g.drawImage(OffButton, 287, 410, null);
                }
                if (UseHpAboveHead == false && Clicked == false
                      && Mouse.isPressed() && CurrX > 287 && CurrX < 358
                      && CurrY > 410 && CurrY < 430) {
                   UseHpAboveHead = true;
                   Clicked = true;
                }
                if (UseHpAboveHead == true && Clicked == false && Mouse.isPressed()
                      && CurrX > 287 && CurrX < 358 && CurrY > 410 && CurrY < 430) {
                   UseHpAboveHead = false;
                   Clicked = true;
                }
     
                // ======= Freeze Timer - NOT ADDED YET! =======
                if (UseFreeze == true) {
                   g.drawImage(OnButton, 179, 352, null);
                } else {
                   g.drawImage(OffButton, 179, 352, null);
                }
                if (UseFreeze == false && Clicked == false && Mouse.isPressed()
                      && CurrX > 179 && CurrX < 250 && CurrY > 352 && CurrY < 372) {
                   UseFreeze = true;
                   Clicked = true;
                }
                if (UseFreeze == true && Clicked == false && Mouse.isPressed()
                      && CurrX > 179 && CurrX < 250 && CurrY > 352 && CurrY < 372) {
                   UseFreeze = false;
                   Clicked = true;
                }
                if (UseFreeze == true && MoveHitPredictor == false
                      && MoveStatGrabber == false && Mouse.isPressed()
                      && CurrX > FreezeX && CurrX < FreezeX + 81 && CurrY > FreezeY
                      && CurrY < FreezeX + 117) {
                   MoveFreeze = true;
                }
                if (MoveFreeze == true) {
                   FreezeX = CurrX - 41;
                   FreezeY = CurrY - 60;
                }
     
                // ======= VenganceTimer, Toggle. =======
                if (UseVengeance == true) {
                   g.drawImage(OnButton, 179, 382, null);
                } else {
                   g.drawImage(OffButton, 179, 382, null);
                }
                if (UseVengeance == false && Clicked == false && Mouse.isPressed()
                      && CurrX > 179 && CurrX < 250 && CurrY > 382 && CurrY < 402) {
                   UseVengeance = true;
                   Clicked = true;
                }
                if (UseVengeance == true && Clicked == false && Mouse.isPressed()
                      && CurrX > 179 && CurrX < 250 && CurrY > 382 && CurrY < 402) {
                   UseVengeance = false;
                   Clicked = true;
                }
     
                // ======= SpecialAttackTimer, Toggle. =======
                if (UseSpecialAttack == true) {
                   g.drawImage(OnButton, 179, 410, null);
                } else {
                   g.drawImage(OffButton, 179, 410, null);
                }
                if (UseSpecialAttack == false && Clicked == false
                      && Mouse.isPressed() && CurrX > 179 && CurrX < 250
                      && CurrY > 410 && CurrY < 430) {
                   UseSpecialAttack = true;
                   Clicked = true;
                }
                if (UseSpecialAttack == true && Clicked == false
                      && Mouse.isPressed() && CurrX > 179 && CurrX < 250
                      && CurrY > 410 && CurrY < 430) {
                   UseSpecialAttack = false;
                   Clicked = true;
                }
     
             }
     
             g.setFont(new Font("Arial", 0, 20));
     
             if (Enemy != null) {
     
                Enemy.getLocation();
                Enemy.getHeight();
     
                Point M = Calculations.isOnScreen((Enemy.getLocation())); //!! 
                if (Calculations.isOnScreen(M) && UseHpAboveHead == true) {
     
                   Character interacting = Players.getLocal().getInteracting();
     
                   if (interacting instanceof RSNPC) {
     
                      g.setColor(new Color(0, 0, 0));
                      g.drawString("Hp: " + EnemyFinalHp + "%", M.x - 35, M.y - 35);
                      if (EnemyFinalHp > 50) {
                         g.setColor(new Color(0, 255, 0));
                      }
                      if (EnemyFinalHp < 51) {
                         g.setColor(new Color(255, 0, 0));
                      }
                      g.drawString("Hp: " + EnemyFinalHp + "%", M.x - 35, M.y - 35);
     
                   } else {
                      if (EnemyFinalHp > 100) {
                         g.setColor(new Color(0, 0, 0));
                         g.drawString("Hp: " + EnemyFinalHp + " / " + EnemyHp,
                               M.x - 50, M.y - 40);
                         if (EnemyFinalHp / EnemyHp * 100 > 50) {
                            g.setColor(new Color(0, 255, 0));
                         }
                         if (EnemyFinalHp / EnemyHp * 100 < 51) {
                            g.setColor(new Color(255, 0, 0));
                         }
                         g.drawString("Hp: " + EnemyFinalHp + " / " + EnemyHp,
                               M.x - 50, M.y - 40);
                      }
     
                      if (EnemyHp == 10) {
                         g.setColor(new Color(0, 0, 0));
                         g.drawString("Hp: " + EnemyFinalHp + "%", M.x - 35,
                               M.y - 40);
                         if (EnemyFinalHp > 50) {
                            g.setColor(new Color(0, 255, 0));
                         }
                         if (EnemyFinalHp < 51) {
                            g.setColor(new Color(255, 0, 0));
                         }
                         g.drawString("Hp: " + EnemyFinalHp + "%", M.x - 35,
                               M.y - 40);
                      }
                   }
                }
     
             }
     
             g.setFont(new Font("Arial", 0, 15));
     
             g.drawImage(Report, 404, 481, null);
             g.setColor(new Color(255, 255, 255));
             g.drawString("" + EnemyName, 411, 497);
     
             if (UseHitPredictor == true) {
     
                g.drawImage(HitPredictor, HitPredX, HitPredY, null);
     
                if (DisplayFor > 0 && Display < 2000) {
                   if (hit > 1000) {
                      hitS = "";
                   } else {
                      hitS = Integer.toString((int) hit);
                      g.setFont(new Font("Arial", 0, 25));
                      g.setColor(new Color(0, 0, 0, DisplayFor * 12));
                      g.drawString("" + hitS, HitPredX + 14, HitPredY + 24);
                      g.setColor(new Color(255, 0, 0, DisplayFor * 12));
                      g.drawString("" + hitS, HitPredX + 13, HitPredY + 23);
                   }
                }
     
             }
     
             if (!(UseStatGrabber == false)) {
     
                g.drawImage(StatGrabber, StatGrabberX + 88, StatGrabberY, null);
     
                g.setFont(new Font("Arial", 0, 12));
     
                g.setColor(new Color(0, 0, 0));
                g.drawString("" + MyAtt, StatGrabberX + 122, StatGrabberY + 13);
                Compare(MyAtt, EnemyAtt);
                g.setColor(C);
                g.drawString("" + MyAtt, StatGrabberX + 121, StatGrabberY + 12);
     
                if (EnemyAtt != 1) {
                   g.setColor(new Color(0, 0, 0));
                   g.drawString("" + EnemyAtt, StatGrabberX + 133,
                         StatGrabberY + 26);
                   Compare(EnemyAtt, MyAtt);
                   g.setColor(C);
                   g.drawString("" + EnemyAtt, StatGrabberX + 132,
                         StatGrabberY + 25);
                }
     
                g.setColor(new Color(0, 0, 0));
                g.drawString("" + MyStr, StatGrabberX + 183, StatGrabberY + 13);
                Compare(MyStr, EnemyStr);
                g.setColor(C);
                g.drawString("" + MyStr, StatGrabberX + 182, StatGrabberY + 12);
     
                if (EnemyStr != 1) {
                   g.setColor(new Color(0, 0, 0));
                   g.drawString("" + EnemyStr, StatGrabberX + 193,
                         StatGrabberY + 26);
                   Compare(EnemyStr, MyStr);
                   g.setColor(C);
                   g.drawString("" + EnemyStr, StatGrabberX + 192,
                         StatGrabberY + 25);
                }
     
                g.setColor(new Color(0, 0, 0));
                g.drawString("" + MyDef, StatGrabberX + 243, StatGrabberY + 13);
                Compare(MyDef, EnemyDef);
                g.setColor(C);
                g.drawString("" + MyDef, StatGrabberX + 242, StatGrabberY + 12);
     
                if (EnemyDef != 1) {
                   g.setColor(new Color(0, 0, 0));
                   g.drawString("" + EnemyDef, StatGrabberX + 252,
                         StatGrabberY + 26);
                   Compare(EnemyDef, MyDef);
                   g.setColor(C);
                   g.drawString("" + EnemyDef, StatGrabberX + 251,
                         StatGrabberY + 25);
                }
     
                g.setColor(new Color(0, 0, 0));
                g.drawString("" + MyHp, StatGrabberX + 298, StatGrabberY + 13);
                Compare(MyHp, EnemyHp);
                g.setColor(C);
                g.drawString("" + MyHp, StatGrabberX + 297, StatGrabberY + 12);
     
                if (EnemyHp > 10) {
                   g.setColor(new Color(0, 0, 0));
                   g.drawString("" + EnemyHp, StatGrabberX + 308, StatGrabberY + 26);
                   Compare(EnemyHp, MyHp);
                   g.setColor(C);
                   g.drawString("" + EnemyHp, StatGrabberX + 307, StatGrabberY + 25);
                }
     
                g.setColor(new Color(0, 0, 0));
                g.drawString("" + MyMagic, StatGrabberX + 363, StatGrabberY + 13);
                Compare(MyMagic, EnemyMagic);
                g.setColor(C);
                g.drawString("" + MyMagic, StatGrabberX + 362, StatGrabberY + 12);
     
                if (EnemyMagic != 1) {
                   g.setColor(new Color(0, 0, 0));
                   g.drawString("" + EnemyMagic, StatGrabberX + 373,
                         StatGrabberY + 26);
                   Compare(EnemyMagic, MyMagic);
                   g.setColor(C);
                   g.drawString("" + EnemyMagic, StatGrabberX + 372,
                         StatGrabberY + 25);
                }
     
                g.setColor(new Color(0, 0, 0));
                g.drawString("" + MyRange, StatGrabberX + 423, StatGrabberY + 13);
                Compare(MyRange, EnemyRange);
                g.setColor(C);
                g.drawString("" + MyRange, StatGrabberX + 422, StatGrabberY + 12);
     
                if (EnemyRange != 1) {
                   g.setColor(new Color(0, 0, 0));
                   g.drawString("" + EnemyRange, StatGrabberX + 433,
                         StatGrabberY + 26);
                   Compare(EnemyRange, MyRange);
                   g.setColor(C);
                   g.drawString("" + EnemyRange, StatGrabberX + 432,
                         StatGrabberY + 25);
                }
     
                g.setColor(new Color(0, 0, 0));
                g.drawString("" + MyPrayer, StatGrabberX + 483, StatGrabberY + 13);
                Compare(MyPrayer, EnemyPrayer);
                g.setColor(C);
                g.drawString("" + MyPrayer, StatGrabberX + 482, StatGrabberY + 12);
     
                if (EnemyPrayer != 1) {
                   g.setColor(new Color(0, 0, 0));
                   g.drawString("" + EnemyPrayer, StatGrabberX + 493,
                         StatGrabberY + 26);
                   Compare(EnemyPrayer, MyPrayer);
                   g.setColor(C);
                   g.drawString("" + EnemyPrayer, StatGrabberX + 492,
                         StatGrabberY + 25);
                   Graphics2D g1 = (Graphics2D) grphcs;
                   g1.setRenderingHints(new RenderingHints(
                         RenderingHints.KEY_ANTIALIASING,
                         RenderingHints.VALUE_ANTIALIAS_ON));
     
                   Player botter = Players.getLocal();
                   if ((players != null) && (inWilderness())) {
                      for (Player p : players) {
                         if ((p != null) && (!p.equals(botter))) {
                            if (GUI_SETTINGS.TILE.enabled()
                                  && p.getLocation().isOnScreen()) {
                               drawTile(g1, p.getLocation(), colorForLevel(p));
                            }
                            if (GUI_SETTINGS.BOUNDING_BOX.enabled()
                                  && p.isOnScreen()) {
                               drawPlayer(g1, p, colorForLevel(p));
                            }
                            if (GUI_SETTINGS.NAME_LEVEL.enabled() && p.isOnScreen()) {
                               drawPlayerInformation(g1, p, colorForLevel(p));
                            }
                         }
                      }
                   }
                }
             }
          }
       }

    You haven't posted the method in question from the Calculations class.

    But regardless, I fear that you may be asking a drawing method to do too much including to do program logic. I would recommend that you completely separate program logic from GUI drawing and that you refactor your code since no class much less a method should be as large as this one method that you've posted.
    Last edited by curmudgeon; August 21st, 2012 at 11:23 AM.

Similar Threads

  1. basic java question
    By jim213mm in forum Java Theory & Questions
    Replies: 2
    Last Post: January 19th, 2012, 01:30 PM
  2. Basic Java question
    By fred2028 in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: September 13th, 2011, 03:54 PM
  3. Basic java question
    By erosgol in forum Java Theory & Questions
    Replies: 5
    Last Post: September 2nd, 2011, 05:24 PM
  4. please answer some basic question
    By togaurav in forum Java Theory & Questions
    Replies: 5
    Last Post: April 16th, 2011, 07:58 AM
  5. [SOLVED] Asking what I suspect to be a very basic question
    By Noobert in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 24th, 2010, 07:42 AM