mirror of
https://github.com/jneug/zeichenmaschine.git
synced 2026-10-12 01:45:18 +02:00
Kleinere Verbesserungen und Formatierungen
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
package schule.ngb.zm.shapes;
|
package schule.ngb.zm.shapes;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import schule.ngb.zm.Options;
|
import schule.ngb.zm.Options;
|
||||||
import schule.ngb.zm.Vector;
|
import schule.ngb.zm.Vector;
|
||||||
|
|
||||||
@@ -30,7 +29,7 @@ public class Arrow extends Line {
|
|||||||
*
|
*
|
||||||
* @param vector
|
* @param vector
|
||||||
*/
|
*/
|
||||||
public Arrow( @NotNull Vector vector ) {
|
public Arrow( Vector vector ) {
|
||||||
this(0, 0, vector.x, vector.y);
|
this(0, 0, vector.x, vector.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +40,7 @@ public class Arrow extends Line {
|
|||||||
* @param vector1
|
* @param vector1
|
||||||
* @param vector2
|
* @param vector2
|
||||||
*/
|
*/
|
||||||
public Arrow( @NotNull Vector vector1, @NotNull Vector vector2 ) {
|
public Arrow( Vector vector1, Vector vector2 ) {
|
||||||
this(vector1.x, vector1.y, vector2.x, vector2.y);
|
this(vector1.x, vector1.y, vector2.x, vector2.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +52,7 @@ public class Arrow extends Line {
|
|||||||
* @param y
|
* @param y
|
||||||
* @param vector
|
* @param vector
|
||||||
*/
|
*/
|
||||||
public Arrow( double x, double y, @NotNull Vector vector ) {
|
public Arrow( double x, double y, Vector vector ) {
|
||||||
this(x, y, x + vector.x, y + vector.y);
|
this(x, y, x + vector.x, y + vector.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +61,7 @@ public class Arrow extends Line {
|
|||||||
*
|
*
|
||||||
* @param line
|
* @param line
|
||||||
*/
|
*/
|
||||||
public Arrow( @NotNull Line line ) {
|
public Arrow( Line line ) {
|
||||||
this(line.x, line.y, line.x2, line.y2);
|
this(line.x, line.y, line.x2, line.y2);
|
||||||
this.copyFrom(line);
|
this.copyFrom(line);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
package schule.ngb.zm.shapes;
|
package schule.ngb.zm.shapes;
|
||||||
|
|
||||||
|
import schule.ngb.zm.Drawable;
|
||||||
import schule.ngb.zm.Options;
|
import schule.ngb.zm.Options;
|
||||||
|
|
||||||
import java.awt.geom.Ellipse2D;
|
import java.awt.geom.Ellipse2D;
|
||||||
|
|
||||||
public class Circle extends Shape {
|
public class Circle extends Shape implements Drawable {
|
||||||
|
|
||||||
protected double radius;
|
protected double radius;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package schule.ngb.zm.shapes;
|
package schule.ngb.zm.shapes;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.awt.geom.Path2D;
|
import java.awt.geom.Path2D;
|
||||||
|
|
||||||
public class CustomShape extends Shape {
|
public class CustomShape extends Shape {
|
||||||
@@ -15,7 +13,7 @@ public class CustomShape extends Shape {
|
|||||||
path = new Path2D.Double();
|
path = new Path2D.Double();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CustomShape( @NotNull CustomShape custom ) {
|
public CustomShape( CustomShape custom ) {
|
||||||
super(custom.x, custom.y);
|
super(custom.x, custom.y);
|
||||||
path = custom.path;
|
path = custom.path;
|
||||||
calculateBounds();
|
calculateBounds();
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ public abstract class FilledShape extends StrokedShape {
|
|||||||
fillColor = color;
|
fillColor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFillColor( Color color, int alpha ) {
|
||||||
|
fillColor = new Color(color, alpha);
|
||||||
|
}
|
||||||
|
|
||||||
public void setFillColor( int gray ) {
|
public void setFillColor( int gray ) {
|
||||||
setFillColor(gray, gray, gray, 255);
|
setFillColor(gray, gray, gray, 255);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
package schule.ngb.zm.shapes;
|
package schule.ngb.zm.shapes;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import schule.ngb.zm.Options;
|
|
||||||
|
|
||||||
import java.awt.geom.Line2D;
|
import java.awt.geom.Line2D;
|
||||||
|
|
||||||
public class Line extends Shape {
|
public class Line extends Shape {
|
||||||
@@ -11,13 +8,13 @@ public class Line extends Shape {
|
|||||||
|
|
||||||
protected double y2;
|
protected double y2;
|
||||||
|
|
||||||
public Line( double x1, double y1, double x2, double y2 ) {
|
public Line(double x1, double y1, double x2, double y2) {
|
||||||
super(x1, y1);
|
super(x1, y1);
|
||||||
this.x2 = x2;
|
this.x2 = x2;
|
||||||
this.y2 = y2;
|
this.y2 = y2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Line( @NotNull Line line ) {
|
public Line(Line line) {
|
||||||
this(line.x, line.y, line.x2, line.y2);
|
this(line.x, line.y, line.x2, line.y2);
|
||||||
copyFrom(line);
|
copyFrom(line);
|
||||||
}
|
}
|
||||||
@@ -26,7 +23,7 @@ public class Line extends Shape {
|
|||||||
return x2;
|
return x2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setX2( double x ) {
|
public void setX2(double x) {
|
||||||
this.x2 = x;
|
this.x2 = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,36 +31,36 @@ public class Line extends Shape {
|
|||||||
return y2;
|
return y2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setY2( double y ) {
|
public void setY2(double y) {
|
||||||
this.y2 = y;
|
this.y2 = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getWidth() {
|
public double getWidth() {
|
||||||
return Math.abs(x2-x);
|
return Math.abs(x2 - x);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getHeight() {
|
public double getHeight() {
|
||||||
return Math.abs(y2-y);
|
return Math.abs(y2 - y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Bounds getBounds() {
|
public Bounds getBounds() {
|
||||||
return new Bounds(Math.min(x,x2), Math.min(y,y2), getWidth(), getHeight());
|
return new Bounds(Math.min(x, x2), Math.min(y, y2), getWidth(), getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void scale( double factor ) {
|
public void scale(double factor) {
|
||||||
super.scale(factor);
|
super.scale(factor);
|
||||||
x2 *= factor;
|
x2 *= factor;
|
||||||
y2 *= factor;
|
y2 *= factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void copyFrom( Shape shape ) {
|
public void copyFrom(Shape shape) {
|
||||||
super.copyFrom(shape);
|
super.copyFrom(shape);
|
||||||
if( shape instanceof Line ) {
|
if (shape instanceof Line) {
|
||||||
Line pLine = (Line) shape;
|
Line pLine = (Line) shape;
|
||||||
x2 = pLine.x2;
|
x2 = pLine.x2;
|
||||||
y2 = pLine.y2;
|
y2 = pLine.y2;
|
||||||
@@ -76,16 +73,16 @@ public class Line extends Shape {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void move( double dx, double dy ) {
|
public void move(double dx, double dy) {
|
||||||
super.move(dx, dy);
|
super.move(dx, dy);
|
||||||
x2 += dx;
|
x2 += dx;
|
||||||
y2 += dx;
|
y2 += dx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void moveTo( double x, double y ) {
|
public void moveTo(double x, double y) {
|
||||||
double dx = x2-this.x;
|
double dx = x2 - this.x;
|
||||||
double dy = y2-this.y;
|
double dy = y2 - this.y;
|
||||||
super.moveTo(x, y);
|
super.moveTo(x, y);
|
||||||
x2 += dx;
|
x2 += dx;
|
||||||
y2 += dy;
|
y2 += dy;
|
||||||
@@ -97,9 +94,11 @@ public class Line extends Shape {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals( Object o ) {
|
public boolean equals(Object o) {
|
||||||
if( this == o ) return true;
|
if (this == o)
|
||||||
if( o == null || getClass() != o.getClass() ) return false;
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
Line pLine = (Line) o;
|
Line pLine = (Line) o;
|
||||||
return super.equals(o) &&
|
return super.equals(o) &&
|
||||||
Double.compare(pLine.x2, x2) == 0 &&
|
Double.compare(pLine.x2, x2) == 0 &&
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package schule.ngb.zm.shapes;
|
package schule.ngb.zm.shapes;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import schule.ngb.zm.Options;
|
import schule.ngb.zm.Options;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ public abstract class StrokedShape extends Constants implements Drawable {
|
|||||||
this.strokeColor = color;
|
this.strokeColor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setStrokeColor( Color color , int alpha ) {
|
||||||
|
this.strokeColor = new Color(color, alpha);
|
||||||
|
}
|
||||||
|
|
||||||
public void setStrokeColor( int gray ) {
|
public void setStrokeColor( int gray ) {
|
||||||
setStrokeColor(gray, gray, gray, 255);
|
setStrokeColor(gray, gray, gray, 255);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user