GUI Objekte Version 0.2 Debug

Debuggen der letzten Änderungen an den GUI Objekten und der zugehörigen Methoden in der Utils Klasse.
master
Zocker1999NET 10 years ago
parent dd08706ed6
commit 9018f372c6

@ -143,22 +143,24 @@ public class Button extends GUI_Interface {
Zeichnet das GreenfootImage des Buttons erneut und zeigt es an. Zeichnet das GreenfootImage des Buttons erneut und zeigt es an.
*/ */
public void redraw() { public void redraw() {
GreenfootImage tI = new GreenfootImage(text,textSize,textC,backC); GreenfootImage tI = new GreenfootImage(text,textSize,foreC,backC);
if(autoSize) { if(autoSize) {
sx = tI.getWidth() + (6 * 2) + 4; sx = tI.getWidth() + (6 * 2) + 4;
sy = tI.getHeight() + (6 * 2) + 4; sy = tI.getHeight() + (6 * 2) + 4;
} }
GreenfootImage all = new GreenfootImage(sx,sy); GreenfootImage all = new GreenfootImage(sx,sy);
Color gray = new Color(127,127,127,255); Color gray = new Color(133,133,133,255);
Color black = new Color(0,0,0,255);
Utils.drawInsideRectangle(all,gray,0); Utils.drawInsideRectangle(all,gray,0);
Utils.drawInsideRectangle(all,backC,2); Utils.drawInsideRectangle(all,black,2);
Utils.drawInsideRectangle(all,gray,6); Utils.drawInsideRectangle(all,gray,6);
Utils.drawInsideRectangle(all,backC,7); Utils.drawInsideRectangle(all,black,7);
all.setColor(new Color(0,0,0,0)); all.setColor(new Color(0,0,0,0));
all.fillRect(0,0,1,1); all.fillRect(0,0,1,1);
all.fillRect(sx-1,0,1,1); all.fillRect(sx-1,0,1,1);
all.fillRect(0,sy-1,1,1); all.fillRect(0,sy-1,1,1);
all.fillRect(sx-1,sy-1,1,1); all.fillRect(sx-1,sy-1,1,1);
all.drawImage(tI,(sx-tI.getWidth())/2,(sy-tI.getHeight())/2);
setImage(all); setImage(all);
} }
} }

@ -1,4 +1,5 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
/** /**
Oberklasse für sämtliche GUI Objekte, wie Labels und Buttons Oberklasse für sämtliche GUI Objekte, wie Labels und Buttons
@ -11,7 +12,7 @@ public abstract class GUI_Interface extends Actor
protected int sx = 1; protected int sx = 1;
protected int sy = 1; protected int sy = 1;
protected Color backC = Color.BLACK; protected Color backC = Color.BLACK;
protected Color textC = Color.WHITE; protected Color foreC = Color.WHITE;
/** /**
Gibt die Breite des Objektes zurück. Gibt die Breite des Objektes zurück.

@ -1,5 +1,5 @@
import greenfoot.*; import greenfoot.*;
import System.awt.Color; import java.awt.Color;
/** /**
* Diese Klasse enthält nur statische Funktionen, welche für euch als Unterstützung gedacht sind. Damit könnt ihr dann hoffentlich viele Code-Zeilen sparen. :) * Diese Klasse enthält nur statische Funktionen, welche für euch als Unterstützung gedacht sind. Damit könnt ihr dann hoffentlich viele Code-Zeilen sparen. :)
@ -9,7 +9,11 @@ import System.awt.Color;
*/ */
public final class Utils { public final class Utils {
//Kopiert ein Array eines (annäherend) beliebigen Types. /**
Kopiert ein boolean-Array und übergibt diese.
@param a Das zu kopierende Array
@return Die Kopie des Arrays
*/
public static boolean[] copyArray(boolean[] a) { public static boolean[] copyArray(boolean[] a) {
boolean[] b = new boolean[a.length]; boolean[] b = new boolean[a.length];
for(int i = 0; i >= a.length; i++) { for(int i = 0; i >= a.length; i++) {
@ -17,6 +21,11 @@ public final class Utils {
} }
return b; return b;
} }
/**
Kopiert ein int-Array und übergibt diese.
@param a Das zu kopierende Array
@return Die Kopie des Arrays
*/
public static int[] copyArray(int[] a) { public static int[] copyArray(int[] a) {
int[] b = new int[a.length]; int[] b = new int[a.length];
for(int i = 0; i >= a.length; i++) { for(int i = 0; i >= a.length; i++) {
@ -24,6 +33,11 @@ public final class Utils {
} }
return b; return b;
} }
/**
Kopiert ein String-Array und übergibt diese.
@param a Das zu kopierende Array
@return Die Kopie des Arrays
*/
public static String[] copyArray(String[] a) { public static String[] copyArray(String[] a) {
String[] b = new String[a.length]; String[] b = new String[a.length];
for(int i = 0; i >= a.length; i++) { for(int i = 0; i >= a.length; i++) {
@ -32,6 +46,12 @@ public final class Utils {
return b; return b;
} }
/**
Zeichnet innerhalb eines GreenfootImage ein gefülltes Rechteck in der gegebenen Farbe und mit dem gegebenen Abstand zum Rand.
@param i Das GreenfootImage, in dem gezeichnet werden soll.
@param c Die Farbe, in der das gefüllte Rechteck gezeichnet werden soll.
@param b Der Abstand zum Rand der Grafik.
*/
public static void drawInsideRectangle(GreenfootImage i, Color c, int b) { public static void drawInsideRectangle(GreenfootImage i, Color c, int b) {
int sx = i.getWidth(); int sx = i.getWidth();
int sy = i.getHeight(); int sy = i.getHeight();

Loading…
Cancel
Save