-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7812f2b
commit 7155abc
Showing
5 changed files
with
125 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
.../woehlke/computer/kurzweil/simulated/evolution/model/food/molecules/LatticeDimension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package org.woehlke.computer.kurzweil.simulated.evolution.model.food.molecules; | ||
|
||
import lombok.*; | ||
import lombok.extern.log4j.Log4j2; | ||
|
||
import java.io.Serializable; | ||
|
||
@Log4j2 | ||
@Getter | ||
@Setter | ||
@ToString | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@EqualsAndHashCode | ||
public class LatticeDimension implements Serializable { | ||
|
||
static final long serialVersionUID = 242L; | ||
|
||
/** | ||
* Horizontal X-Coordinate. Also used as Width; | ||
*/ | ||
private int width; | ||
|
||
/** | ||
* Vertical Y-Coordinate. Also used as Height; | ||
*/ | ||
private int height; | ||
|
||
public void absoluteValue() { | ||
width *= Integer.signum(width); | ||
height *= Integer.signum(height); | ||
} | ||
|
||
public void plus(LatticeDimension p) { | ||
this.width += p.getWidth(); | ||
this.height += p.getHeight(); | ||
absoluteValue(); | ||
} | ||
|
||
public LatticeDimension copy() { | ||
return new LatticeDimension( | ||
this.getWidth(), | ||
this.getHeight() | ||
); | ||
} | ||
|
||
public LatticePoint toLatticePoint() { | ||
return new LatticePoint( | ||
this.getWidth(), | ||
this.getHeight() | ||
); | ||
} | ||
|
||
public static LatticeDimension of(LatticePoint p) { | ||
return new LatticeDimension(p.getX(), p.getY()); | ||
} | ||
|
||
public static LatticeDimension of(LatticeDimension p) { | ||
return LatticeDimension.of(p.toLatticePoint()); | ||
} | ||
|
||
public static LatticeDimension of(int width, int height) { | ||
return new LatticeDimension(width, height); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
.../woehlke/computer/kurzweil/simulated/evolution/model/food/molecules/LatticeRectangle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.woehlke.computer.kurzweil.simulated.evolution.model.food.molecules; | ||
|
||
import lombok.*; | ||
import lombok.extern.log4j.Log4j2; | ||
|
||
import java.io.Serializable; | ||
|
||
@Log4j2 | ||
@Getter | ||
@ToString | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@EqualsAndHashCode | ||
public class LatticeRectangle implements Serializable { | ||
|
||
static final long serialVersionUID = 242L; | ||
|
||
private LatticePoint start; | ||
|
||
private LatticeDimension dimension; | ||
|
||
public static LatticeRectangle of(LatticePoint start, LatticeDimension dimension){ | ||
LatticeRectangle lb = new LatticeRectangle(start, dimension); | ||
return lb; | ||
} | ||
|
||
public static LatticeRectangle of(int startX, int startY, int width, int height){ | ||
LatticePoint start = new LatticePoint(startX, startY); | ||
LatticeDimension dimension = new LatticeDimension(width, height); | ||
LatticeRectangle lb = new LatticeRectangle(start, dimension); | ||
return lb; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters