mirror of
https://github.com/jneug/zeichenmaschine.git
synced 2026-04-14 06:33:34 +02:00
GradientPaint durch MultipleGradientPaint ersetzt
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
package schule.ngb.zm;
|
||||
|
||||
import java.awt.GradientPaint;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Paint;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Basisimplementierung der {@link Strokeable} und {@link Fillable} APIs.
|
||||
@@ -51,7 +48,7 @@ public abstract class BasicDrawable extends Constants implements Strokeable, Fil
|
||||
* Der aktuelle Farbverlauf des Objektes oder {@code null}, wenn es keinen
|
||||
* Farbverlauf besitzt.
|
||||
*/
|
||||
protected GradientPaint fill = null;
|
||||
protected MultipleGradientPaint fill = null;
|
||||
|
||||
|
||||
// Implementierung Drawable Interface
|
||||
@@ -98,11 +95,14 @@ public abstract class BasicDrawable extends Constants implements Strokeable, Fil
|
||||
*/
|
||||
@Override
|
||||
public void setFill( Paint fill ) {
|
||||
if( fill instanceof Color ) {
|
||||
this.setFillColor((Color) fill);
|
||||
} else if( fill instanceof GradientPaint ) {
|
||||
if( fill == null ) {
|
||||
this.fill = null;
|
||||
} else if( fill instanceof Color ) {
|
||||
this.fillColor = ((Color) fill);
|
||||
this.fill = null;
|
||||
} else if( fill instanceof MultipleGradientPaint ) {
|
||||
this.fillColor = null;
|
||||
this.fill = (GradientPaint) fill;
|
||||
this.fill = (MultipleGradientPaint) fill;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ public abstract class BasicDrawable extends Constants implements Strokeable, Fil
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public GradientPaint getGradient() {
|
||||
public MultipleGradientPaint getGradient() {
|
||||
return fill;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,7 @@ package schule.ngb.zm;
|
||||
|
||||
import schule.ngb.zm.shapes.Shape;
|
||||
|
||||
import java.awt.GradientPaint;
|
||||
import java.awt.Paint;
|
||||
import java.awt.RadialGradientPaint;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* {@link Drawable} Klassen, die mit einer Füllung versehen werden können.
|
||||
@@ -78,7 +76,7 @@ public interface Fillable extends Drawable {
|
||||
*/
|
||||
default boolean hasGradient() {
|
||||
Paint fill = getFill();
|
||||
return fill instanceof GradientPaint;
|
||||
return fill instanceof MultipleGradientPaint;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,9 +193,9 @@ public interface Fillable extends Drawable {
|
||||
*
|
||||
* @return Der aktuelle Farbverlauf oder {@code null}.
|
||||
*/
|
||||
default GradientPaint getGradient() {
|
||||
default MultipleGradientPaint getGradient() {
|
||||
if( hasGradient() ) {
|
||||
return (GradientPaint) getFill();
|
||||
return (MultipleGradientPaint) getFill();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -216,9 +214,11 @@ public interface Fillable extends Drawable {
|
||||
* @param to Farbe am Endpunkt.
|
||||
*/
|
||||
default void setGradient( double fromX, double fromY, Color from, double toX, double toY, Color to ) {
|
||||
setFill(new GradientPaint(
|
||||
(float) fromX, (float) fromY, from.getJavaColor(),
|
||||
(float) toX, (float) toY, to.getJavaColor()
|
||||
setFill(new LinearGradientPaint(
|
||||
(float) fromX, (float) fromY,
|
||||
(float) toX, (float) toY,
|
||||
new float[]{0f, 1f},
|
||||
new java.awt.Color[]{from.getJavaColor(), to.getJavaColor()}
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -617,8 +617,7 @@ public class DrawingLayer extends Layer implements Strokeable, Fillable {
|
||||
}
|
||||
|
||||
protected void drawShape( Shape shape ) {
|
||||
if( shapeDelegate.getStrokeColor() != null && shapeDelegate.getStrokeColor().getAlpha() > 0
|
||||
&& shapeDelegate.getStrokeWeight() > 0.0 ) {
|
||||
if( shapeDelegate.hasStroke() ) {
|
||||
drawing.setColor(shapeDelegate.getStrokeColor().getJavaColor());
|
||||
drawing.setStroke(shapeDelegate.getStroke());
|
||||
drawing.draw(shape);
|
||||
@@ -783,6 +782,10 @@ public class DrawingLayer extends Layer implements Strokeable, Fillable {
|
||||
drawing.rotate(Math.toRadians(pAngle));
|
||||
}
|
||||
|
||||
public void rotate( double pAngle, double centerX, double centerY ) {
|
||||
drawing.rotate(Math.toRadians(pAngle), centerX, centerY);
|
||||
}
|
||||
|
||||
public void shear( double dx, double dy ) {
|
||||
drawing.shear(dx, dy);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package schule.ngb.zm.layers;
|
||||
|
||||
import schule.ngb.zm.*;
|
||||
import schule.ngb.zm.Color;
|
||||
import schule.ngb.zm.Fillable;
|
||||
import schule.ngb.zm.Strokeable;
|
||||
|
||||
import java.awt.GradientPaint;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Paint;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Path2D;
|
||||
import java.util.ArrayList;
|
||||
@@ -292,7 +290,7 @@ public class TurtleLayer extends Layer implements Strokeable, Fillable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GradientPaint getGradient() {
|
||||
public MultipleGradientPaint getGradient() {
|
||||
return mainTurtle.getGradient();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user