Package schule.ngb.zm
Class BasicDrawable
java.lang.Object
schule.ngb.zm.Constants
schule.ngb.zm.BasicDrawable
- All Implemented Interfaces:
Drawable,Fillable,Strokeable
- Direct Known Subclasses:
Card,Shape,TurtleLayer.Turtle
Basisimplementierung der
Strokeable und Fillable APIs.
Die Klasse bietet eine Grundlage zur Implementierung eigener Zeichenobjekte,
die eine Füllung und eine Konturlinie haben können.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected MultipleGradientPaintDer aktuelle Farbverlauf des Objektes odernull, wenn es keinen Farbverlauf besitzt.protected ColorDie aktuelle Füllfarbe der Form odernull, wenn das Objekt nicht gefüllt werden soll.protected StrokeCache für den aktuellenStrokeder Kontur.protected ColorAktuelle Farbe der Konturlinie odernull, wenn das Objekt ohne Kontur dargestellt werden soll.protected Options.StrokeJoinDie Art der Kantenverbindungen von Linien.protected Options.StrokeTypeDie Art der Konturlinie.protected doubleDie Dicke der Konturlinie.protected booleanOb das Objekt gezeichnet werden soll.Fields inherited from class schule.ngb.zm.Constants
APP_NAME, APP_VERSION, APP_VERSION_MAJ, APP_VERSION_MIN, APP_VERSION_REV, ARROW, BEVEL, BLACK, BLUE, BOLD, BROWN, canvasHeight, canvasWidth, CENTER, CLOSED, cmouseX, cmouseY, CROSS, CYAN, DARKGRAY, DASHED, DEFAULT_ANIM_RUNTIME, DEFAULT_BACKGROUND, DEFAULT_BUFFER, DEFAULT_EASING, DEFAULT_FILLCOLOR, DEFAULT_FONTSIZE, DEFAULT_FPS, DEFAULT_HEIGHT, DEFAULT_STROKECOLOR, DEFAULT_STROKEWEIGHT, DEFAULT_WIDTH, delta, DOTTED, DOWN, DOWNLEFT, DOWNRIGHT, EAST, FILLED, framesPerSecond, GRAY, GREEN, HALF_PI, HAND, ITALIC, key, KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_A, KEY_ALT, KEY_B, KEY_BACK_SPACE, KEY_C, KEY_CANCEL, KEY_CAPS_LOCK, KEY_CLEAR, KEY_COMMA, KEY_CONTROL, KEY_D, KEY_DOWN, KEY_E, KEY_END, KEY_ENTER, KEY_EQUALS, KEY_ESCAPE, KEY_F, KEY_G, KEY_H, KEY_HOME, KEY_I, KEY_J, KEY_K, KEY_L, KEY_LEFT, KEY_M, KEY_MINUS, KEY_N, KEY_O, KEY_P, KEY_PAGE_DOWN, KEY_PAGE_UP, KEY_PAUSE, KEY_PERIOD, KEY_Q, KEY_R, KEY_RIGHT, KEY_S, KEY_SEMICOLON, KEY_SHIFT, KEY_SLASH, KEY_SPACE, KEY_T, KEY_TAB, KEY_U, KEY_UP, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, keyCode, keyEvent, keyPressed, LEFT, LIGHTGRAY, LINES, LINUX, MACOS, MAGENTA, MIDDLE, MITER, MOUSE1, MOUSE2, MOUSE3, mouseButton, mouseEvent, mousePressed, mouseX, mouseY, MOVE, NOMOUSE, NORTH, NORTHEAST, NORTHWEST, OPEN, ORANGE, PI, PIE, PINK, PLAIN, pmouseX, pmouseY, PURPLE, QUARTER_PI, RED, RIGHT, ROUND, runtime, screenHeight, screenWidth, SOLID, SOUTH, SOUTHEAST, SOUTHWEST, TEXT, tick, TWO_PI, UP, UPLEFT, UPRIGHT, WAIT, WEST, WHITE, WINDOWS, YELLOW -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voiddraw(Graphics2D graphics) Wird aufgerufen, um das Objekt auf die Zeichenfläche graphics zu zeichnen.getFill()Gibt die aktuell gesetzte Füllung zurück.Gibt die aktuelle Füllfarbe der Form zurück.Gibt den aktuellen Farbverlauf der Form zurück.Gibt einStroke-Objekt mit den aktuell gesetzten Eigenschaften zurück.Gibt die aktuelle Farbe der Konturlinie zurück.Gibt die Art der Konturverbindungen zurück.Gibt die Art der Konturlinie zurück.doubleGibt die Dicke der Konturlinie zurück.booleanGibt an, ob eine Füllfarbe konfiguriert ist.booleanGibt an, ob ein Farbverlauf konfiguriert ist.voidhide()Versteckt das Objekt.booleanOb das Objekt angezeigt bzw. gezeichnet werden soll.voidSetzt die Füllung direkt auf das angegebenePaint-Objekt.voidsetFillColor(Color color) Setzt die Füllfarbe auf die angegebene Farbe.voidSetzt denStrokefür die Konturlinie direkt.voidsetStrokeColor(Color color) Setzt die Farbe der Konturlinie auf die angegebene Farbe.voidSetzt den Typ der Konturverbindungen.voidSetzt den Typ der Kontur.voidsetStrokeWeight(double weight) Setzt die Dicke der Konturlinie.voidshow()Zeigt das Objekt an.voidtoggle()Versteckt da Objekt, wenn es derzeit angezeigt wird und zeigt es andernfalls an.Methods inherited from class schule.ngb.zm.Constants
abs, arccos, arcsin, arctan, asBool, asBool, asBool, asBool, asBool, asBool, asBool, asBool, asBool, asDouble, asDouble, asDouble, asDouble, asDouble, asDouble, asDouble, asDouble, asDouble, asInt, asInt, asInt, asInt, asInt, asInt, asInt, asInt, asInt, avg, binary, ceil, choice, choice, choice, choice, color, color, color, color, colorHsb, colorHsl, cos, degrees, distance, floor, fromBinary, fromHex, getRandom, hex, interpolate, limit, limit, loadImage, map, max, max, min, min, morph, noise, noise, noise, noise, pow, radians, random, random, random, random, random, randomBool, randomBool, randomBool, randomColor, randomGaussian, randomNiceColor, round, setSeed, shuffle, shuffle, shuffle, shuffle, sign, sin, sqrt, sum, tanMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface schule.ngb.zm.Fillable
hasFill, noFill, noGradient, resetFill, setFillColor, setFillColor, setFillColor, setFillColor, setFillColor, setGradient, setGradient, setGradient, setGradientMethods inherited from interface schule.ngb.zm.Strokeable
hasStroke, noStroke, resetStroke, setStrokeColor, setStrokeColor, setStrokeColor, setStrokeColor, setStrokeColor
-
Field Details
-
visible
protected boolean visibleOb das Objekt gezeichnet werden soll. -
strokeColor
Aktuelle Farbe der Konturlinie odernull, wenn das Objekt ohne Kontur dargestellt werden soll. -
strokeWeight
protected double strokeWeightDie Dicke der Konturlinie. Wird nicht kleiner als 0. -
strokeType
Die Art der Konturlinie. -
strokeJoin
Die Art der Kantenverbindungen von Linien. -
stroke
Cache für den aktuellenStrokeder Kontur. Wird nach Änderung einer der Kontureigenschaften aufnullgesetzt und beim nächsten Zeichnen neu erstellt. -
fillColor
Die aktuelle Füllfarbe der Form odernull, wenn das Objekt nicht gefüllt werden soll. -
fill
Der aktuelle Farbverlauf des Objektes odernull, wenn es keinen Farbverlauf besitzt.
-
-
Constructor Details
-
BasicDrawable
public BasicDrawable()
-
-
Method Details
-
isVisible
public boolean isVisible()Ob das Objekt angezeigt bzw. gezeichnet werden soll. -
hide
public void hide()Versteckt das Objekt. -
show
public void show()Zeigt das Objekt an. -
toggle
public void toggle()Versteckt da Objekt, wenn es derzeit angezeigt wird und zeigt es andernfalls an. -
draw
Description copied from interface:DrawableWird aufgerufen, um das Objekt auf die Zeichenfläche graphics zu zeichnen.Das Objekt muss dafür Sorge tragen, dass der Zustand der Zeichenfläche (Transformationsmatrix, Farbe, ...) erhalten bleibt. Das Objekt sollte also etwaige Änderungen am Ende des Aufrufs wieder rückgängig machen.
-
setFill
Description copied from interface:FillableSetzt die Füllung direkt auf das angegebenePaint-Objekt. -
getFill
Description copied from interface:FillableGibt die aktuell gesetzte Füllung zurück.Die Art der Füllung kann anhand der Abfragen
Fillable.hasFillColor()undFillable.hasGradient()ermittelt werden. -
hasFillColor
public boolean hasFillColor()Description copied from interface:FillableGibt an, ob eine Füllfarbe konfiguriert ist.Im Gegensatz zu
Fillable.hasFill()prüft die Methode nicht, ob die Füllfarbe transparent ist.- Specified by:
hasFillColorin interfaceFillable- Returns:
true, wenn eine Füllfarbe gesetzt ist.
-
hasGradient
public boolean hasGradient()Description copied from interface:FillableGibt an, ob ein Farbverlauf konfiguriert ist.- Specified by:
hasGradientin interfaceFillable- Returns:
true, wenn ein Farbverlauf gesetzt ist.
-
getFillColor
Description copied from interface:FillableGibt die aktuelle Füllfarbe der Form zurück.- Specified by:
getFillColorin interfaceFillable- Returns:
- Die aktuelle Füllfarbe oder
null.
-
setFillColor
Description copied from interface:FillableSetzt die Füllfarbe auf die angegebene Farbe.- Specified by:
setFillColorin interfaceFillable- Parameters:
color- Die neue Füllfarbe odernull.- See Also:
-
getGradient
Description copied from interface:FillableGibt den aktuellen Farbverlauf der Form zurück.- Specified by:
getGradientin interfaceFillable- Returns:
- Der aktuelle Farbverlauf oder
null.
-
setStroke
Description copied from interface:StrokeableSetzt denStrokefür die Konturlinie direkt.- Specified by:
setStrokein interfaceStrokeable- Parameters:
stroke- EinStroke-Objekt.
-
getStroke
Description copied from interface:StrokeableGibt einStroke-Objekt mit den aktuell gesetzten Eigenschaften zurück.- Specified by:
getStrokein interfaceStrokeable- Returns:
- Ein
Strokemit den passenden Kontureigenschaften.
-
getStrokeColor
Description copied from interface:StrokeableGibt die aktuelle Farbe der Konturlinie zurück.- Specified by:
getStrokeColorin interfaceStrokeable- Returns:
- Die Konturfarbe oder
null.
-
setStrokeColor
Description copied from interface:StrokeableSetzt die Farbe der Konturlinie auf die angegebene Farbe.- Specified by:
setStrokeColorin interfaceStrokeable- Parameters:
color- Die neue Farbe der Konturlinie.- See Also:
-
getStrokeWeight
public double getStrokeWeight()Description copied from interface:StrokeableGibt die Dicke der Konturlinie zurück.- Specified by:
getStrokeWeightin interfaceStrokeable- Returns:
- Die aktuelle Dicke der Linie.
-
setStrokeWeight
public void setStrokeWeight(double weight) Description copied from interface:StrokeableSetzt die Dicke der Konturlinie. Die Dicke muss größer 0 sein. Wird 0 übergeben, dann wird keine Kontur mehr angezeigt.- Specified by:
setStrokeWeightin interfaceStrokeable- Parameters:
weight- Die Dicke der Konturlinie.
-
getStrokeType
Description copied from interface:StrokeableGibt die Art der Konturlinie zurück.- Specified by:
getStrokeTypein interfaceStrokeable- Returns:
- Die aktuelle Art der Konturlinie.
- See Also:
-
setStrokeType
Description copied from interface:StrokeableSetzt den Typ der Kontur. Erlaubte Werte sindConstants.DASHED,Constants.DOTTEDundConstants.SOLID.- Specified by:
setStrokeTypein interfaceStrokeable- Parameters:
type- Eine der möglichen Konturarten.- See Also:
-
getStrokeJoin
Description copied from interface:StrokeableGibt die Art der Konturverbindungen zurück.- Specified by:
getStrokeJoinin interfaceStrokeable- Returns:
- Die aktuelle Art der Konturverbindungen.
- See Also:
-
setStrokeJoin
Description copied from interface:StrokeableSetzt den Typ der Konturverbindungen. Erlaubte Werte sindConstants.ROUND,Constants.MITERundConstants.BEVEL.- Specified by:
setStrokeJoinin interfaceStrokeable- Parameters:
join- Eine der möglichen Konturverbindungen.- See Also:
-