Vergleich von Options.Direction Enumerations angepasst

This commit is contained in:
ngb
2022-06-13 21:32:21 +02:00
parent d2d6a77107
commit 0f8555c378
3 changed files with 29 additions and 14 deletions

View File

@@ -456,16 +456,16 @@ public class DrawingLayer extends Layer {
// anchor == CENTER
Point2D.Double anchorPoint = new Point2D.Double(x - whalf, y - hhalf);
if( NORTH.is(anchor) ) {
if( NORTH.in(anchor) ) {
anchorPoint.y += hhalf;
}
if( SOUTH.is(anchor) ) {
if( SOUTH.in(anchor) ) {
anchorPoint.y -= hhalf;
}
if( WEST.is(anchor) ) {
if( WEST.in(anchor) ) {
anchorPoint.x += whalf;
}
if( EAST.is(anchor) ) {
if( EAST.in(anchor) ) {
anchorPoint.x -= whalf;
}

View File

@@ -3,11 +3,13 @@ package schule.ngb.zm;
import java.awt.geom.Arc2D;
/**
* Diese Klasse sammelt Enumerationen, die verschiedene Eigenschaften der
* zu zeichnenden Formen darstellen.
* Diese Klasse sammelt Enumerationen, die verschiedene Eigenschaften der zu
* zeichnenden Formen darstellen.
*/
public final class Options {
private Options() {}
private Options() {
}
public enum StrokeType {
SOLID, DASHED, DOTTED
@@ -19,7 +21,9 @@ public final class Options {
public enum PathType {
OPEN(Arc2D.OPEN), CLOSED(Arc2D.CHORD), PIE(Arc2D.PIE);
public final int awt_type;
PathType( int type ) {
awt_type = type;
}
@@ -55,14 +59,25 @@ public final class Options {
RIGHT(EAST.mask);
public final byte mask;
Direction( int mask ) {
this.mask = (byte) mask;
}
public boolean is( int mask ) {
public boolean in( int mask ) {
return (mask & this.mask) == this.mask;
}
public boolean is( Direction dir ) {
return (dir.mask & this.mask) == this.mask;
public boolean in( Direction dir ) {
return in(dir.mask);
}
public boolean contains( int mask ) {
return (mask & this.mask) == mask;
}
public boolean contains( Direction dir ) {
return contains(dir.mask);
}
}

View File

@@ -129,16 +129,16 @@ public abstract class Shape extends FilledShape {
anchorpoint.x = bHalf;
anchorpoint.y = hHalf;
if( NORTH.is(anchor) ) {
if( NORTH.in(anchor) ) {
anchorpoint.y -= hHalf;
}
if( SOUTH.is(anchor) ) {
if( SOUTH.in(anchor) ) {
anchorpoint.y += hHalf;
}
if( WEST.is(anchor) ) {
if( WEST.in(anchor) ) {
anchorpoint.x -= bHalf;
}
if( EAST.is(anchor) ) {
if( EAST.in(anchor) ) {
anchorpoint.x += bHalf;
}