|
@@ -26,9 +26,9 @@ import holeg.interfaces.GraphEditable.GraphType;
|
|
import holeg.model.HolonElement;
|
|
import holeg.model.HolonElement;
|
|
import holeg.ui.controller.Control;
|
|
import holeg.ui.controller.Control;
|
|
import holeg.ui.model.Model;
|
|
import holeg.ui.model.Model;
|
|
-import holeg.utility.Maths;
|
|
|
|
-import holeg.utility.Vector2Float;
|
|
|
|
-import holeg.utility.Vector2Int;
|
|
|
|
|
|
+import holeg.utility.math.Maths;
|
|
|
|
+import holeg.utility.math.vector.Vec2f;
|
|
|
|
+import holeg.utility.math.vector.Vec2i;
|
|
|
|
|
|
/**
|
|
/**
|
|
* This Class represents a Graph where the User can model the behavior of
|
|
* This Class represents a Graph where the User can model the behavior of
|
|
@@ -65,7 +65,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
}
|
|
}
|
|
|
|
|
|
private ArrayList<Series> seriesList = new ArrayList<Series>();
|
|
private ArrayList<Series> seriesList = new ArrayList<Series>();
|
|
- private Vector2Int editPosition;
|
|
|
|
|
|
+ private Vec2i editPosition;
|
|
private Optional<Series> actualSeries;
|
|
private Optional<Series> actualSeries;
|
|
|
|
|
|
private class GlobalCurve {
|
|
private class GlobalCurve {
|
|
@@ -149,13 +149,13 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
// sample curve
|
|
// sample curve
|
|
for (int i = 0; i < model.getMaxIterations(); i++) {
|
|
for (int i = 0; i < model.getMaxIterations(); i++) {
|
|
curve.points.add(new UnitGraphPoint((double) i / (double)model.getMaxIterations(),
|
|
curve.points.add(new UnitGraphPoint((double) i / (double)model.getMaxIterations(),
|
|
- Maths.inverseLinearInterpolation(curve.minEnergy, curve.maxEnergy, sample[i]), false));
|
|
|
|
|
|
+ Maths.invLerp(curve.minEnergy, curve.maxEnergy, sample[i]), false));
|
|
}
|
|
}
|
|
// update displayPosition
|
|
// update displayPosition
|
|
for (UnitGraphPoint p : curve.points) {
|
|
for (UnitGraphPoint p : curve.points) {
|
|
p.calcDisplayedPosition(border, widthWithBorder, heightWithBorder);
|
|
p.calcDisplayedPosition(border, widthWithBorder, heightWithBorder);
|
|
}
|
|
}
|
|
- double zeroLineYPos = Maths.inverseLinearInterpolation(curve.minEnergy, curve.maxEnergy, 0.0);
|
|
|
|
|
|
+ double zeroLineYPos = Maths.invLerp(curve.minEnergy, curve.maxEnergy, 0.0);
|
|
curve.zeroLinePoints.add(new UnitGraphPoint(0.0,zeroLineYPos, false));
|
|
curve.zeroLinePoints.add(new UnitGraphPoint(0.0,zeroLineYPos, false));
|
|
curve.zeroLinePoints.add(new UnitGraphPoint(1.0,zeroLineYPos, false));
|
|
curve.zeroLinePoints.add(new UnitGraphPoint(1.0,zeroLineYPos, false));
|
|
for (UnitGraphPoint p : curve.zeroLinePoints) {
|
|
for (UnitGraphPoint p : curve.zeroLinePoints) {
|
|
@@ -315,8 +315,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
int lPeriod = series.element.getLocalPeriod();
|
|
int lPeriod = series.element.getLocalPeriod();
|
|
where = ((double) cur % lPeriod) / ((double) lPeriod);
|
|
where = ((double) cur % lPeriod) / ((double) lPeriod);
|
|
}
|
|
}
|
|
- Vector2Int oben = new Vector2Int(border + (int) (where * widthWithBorder), 0);
|
|
|
|
- Vector2Int unten = new Vector2Int(border + (int) (where * widthWithBorder),
|
|
|
|
|
|
+ Vec2i oben = new Vec2i(border + (int) (where * widthWithBorder), 0);
|
|
|
|
+ Vec2i unten = new Vec2i(border + (int) (where * widthWithBorder),
|
|
2 * border + heightWithBorder);
|
|
2 * border + heightWithBorder);
|
|
g.setColor(series.color);
|
|
g.setColor(series.color);
|
|
drawLine(g, oben, unten);
|
|
drawLine(g, oben, unten);
|
|
@@ -329,8 +329,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
int lPeriod = getFirstLocalPeriod();
|
|
int lPeriod = getFirstLocalPeriod();
|
|
where = ((double) cur % lPeriod) / ((double) lPeriod);
|
|
where = ((double) cur % lPeriod) / ((double) lPeriod);
|
|
}
|
|
}
|
|
- Vector2Int oben = new Vector2Int(border + (int) (where * widthWithBorder), 0);
|
|
|
|
- Vector2Int unten = new Vector2Int(border + (int) (where * widthWithBorder), 2 * border + heightWithBorder);
|
|
|
|
|
|
+ Vec2i oben = new Vec2i(border + (int) (where * widthWithBorder), 0);
|
|
|
|
+ Vec2i unten = new Vec2i(border + (int) (where * widthWithBorder), 2 * border + heightWithBorder);
|
|
g.setColor(dotColor);
|
|
g.setColor(dotColor);
|
|
drawLine(g, oben, unten);
|
|
drawLine(g, oben, unten);
|
|
}
|
|
}
|
|
@@ -347,7 +347,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
* @param start the Position of one end of the line to draw.
|
|
* @param start the Position of one end of the line to draw.
|
|
* @param end the other Ends Position of the Line to draw.
|
|
* @param end the other Ends Position of the Line to draw.
|
|
*/
|
|
*/
|
|
- private void drawLine(Graphics2D g, Vector2Int start, Vector2Int end) {
|
|
|
|
|
|
+ private void drawLine(Graphics2D g, Vec2i start, Vec2i end) {
|
|
Path2D.Double path = new Path2D.Double();
|
|
Path2D.Double path = new Path2D.Double();
|
|
path.moveTo(start.getX(), start.getY());
|
|
path.moveTo(start.getX(), start.getY());
|
|
path.lineTo(end.getX(), end.getY());
|
|
path.lineTo(end.getX(), end.getY());
|
|
@@ -362,7 +362,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
*
|
|
*
|
|
* @param start The Position to start the Curve.
|
|
* @param start The Position to start the Curve.
|
|
*/
|
|
*/
|
|
- private Path2D.Double initBezier(Vector2Int start) {
|
|
|
|
|
|
+ private Path2D.Double initBezier(Vec2i start) {
|
|
// Good Source for basic understanding for Bezier Curves
|
|
// Good Source for basic understanding for Bezier Curves
|
|
// http://www.theappguruz.com/blog/bezier-curve-in-games
|
|
// http://www.theappguruz.com/blog/bezier-curve-in-games
|
|
Path2D.Double path = new Path2D.Double();
|
|
Path2D.Double path = new Path2D.Double();
|
|
@@ -381,7 +381,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
* @param actaul the actual Position of the Path.
|
|
* @param actaul the actual Position of the Path.
|
|
* @param target the end Position of the Curve.
|
|
* @param target the end Position of the Curve.
|
|
*/
|
|
*/
|
|
- private void curveTo(Path2D.Double path, Vector2Int actual, Vector2Int target) {
|
|
|
|
|
|
+ private void curveTo(Path2D.Double path, Vec2i actual, Vec2i target) {
|
|
double mitte = (actual.getX() + target.getX()) * 0.5;
|
|
double mitte = (actual.getX() + target.getX()) * 0.5;
|
|
path.curveTo(mitte, actual.getY(), mitte, target.getY(), target.getX(), target.getY());
|
|
path.curveTo(mitte, actual.getY(), mitte, target.getY(), target.getX(), target.getY());
|
|
}
|
|
}
|
|
@@ -395,7 +395,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
* @param g to draw.
|
|
* @param g to draw.
|
|
* @param p the position of the Dot.
|
|
* @param p the position of the Dot.
|
|
*/
|
|
*/
|
|
- private void drawDot(Graphics2D g, Vector2Int p) {
|
|
|
|
|
|
+ private void drawDot(Graphics2D g, Vec2i p) {
|
|
g.fillOval(p.getX() - dotSize / 2, p.getY() - dotSize / 2, dotSize, dotSize);
|
|
g.fillOval(p.getX() - dotSize / 2, p.getY() - dotSize / 2, dotSize, dotSize);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -410,16 +410,16 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
private void drawBoolGraph(Graphics2D g, Series series) {
|
|
private void drawBoolGraph(Graphics2D g, Series series) {
|
|
if (series.points.size() <= 1)
|
|
if (series.points.size() <= 1)
|
|
return;
|
|
return;
|
|
- LinkedList<Vector2Int> cornerPoints = new LinkedList<Vector2Int>();
|
|
|
|
|
|
+ LinkedList<Vec2i> cornerPoints = new LinkedList<Vec2i>();
|
|
ListIterator<UnitGraphPoint> iter = series.points.listIterator();
|
|
ListIterator<UnitGraphPoint> iter = series.points.listIterator();
|
|
- Vector2Int actual = series.points.getFirst().displayedPosition;
|
|
|
|
|
|
+ Vec2i actual = series.points.getFirst().displayedPosition;
|
|
Path2D.Double path = new Path2D.Double();
|
|
Path2D.Double path = new Path2D.Double();
|
|
path.moveTo(actual.getX(), actual.getY());
|
|
path.moveTo(actual.getX(), actual.getY());
|
|
while (iter.hasNext()) {
|
|
while (iter.hasNext()) {
|
|
- Vector2Int target = iter.next().displayedPosition;
|
|
|
|
|
|
+ Vec2i target = iter.next().displayedPosition;
|
|
// BooleanConnection
|
|
// BooleanConnection
|
|
path.lineTo(target.getX(), actual.getY()); // line to corner
|
|
path.lineTo(target.getX(), actual.getY()); // line to corner
|
|
- cornerPoints.add(new Vector2Int(target.getX(), actual.getY())); // save corner
|
|
|
|
|
|
+ cornerPoints.add(new Vec2i(target.getX(), actual.getY())); // save corner
|
|
path.lineTo(target.getX(), target.getY()); // line to next Point
|
|
path.lineTo(target.getX(), target.getY()); // line to next Point
|
|
|
|
|
|
actual = target;
|
|
actual = target;
|
|
@@ -427,7 +427,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
g.draw(path);
|
|
g.draw(path);
|
|
// Draw the Points on the Corner that dont exist in Data but should be visual
|
|
// Draw the Points on the Corner that dont exist in Data but should be visual
|
|
g.setColor(dotColor);
|
|
g.setColor(dotColor);
|
|
- for (Vector2Int p : cornerPoints) {
|
|
|
|
|
|
+ for (Vec2i p : cornerPoints) {
|
|
drawDot(g, p);
|
|
drawDot(g, p);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -442,8 +442,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
* @param g2D to draw.
|
|
* @param g2D to draw.
|
|
*/
|
|
*/
|
|
private void drawBoolGraphInEditMode(Graphics2D g, Series series) {
|
|
private void drawBoolGraphInEditMode(Graphics2D g, Series series) {
|
|
- LinkedList<Vector2Int> before = new LinkedList<Vector2Int>();
|
|
|
|
- LinkedList<Vector2Int> after = new LinkedList<Vector2Int>();
|
|
|
|
|
|
+ LinkedList<Vec2i> before = new LinkedList<Vec2i>();
|
|
|
|
+ LinkedList<Vec2i> after = new LinkedList<Vec2i>();
|
|
for (UnitGraphPoint p : series.points) {
|
|
for (UnitGraphPoint p : series.points) {
|
|
if (p.displayedPosition.getX() < editPosition.getX())
|
|
if (p.displayedPosition.getX() < editPosition.getX())
|
|
before.add(p.displayedPosition);
|
|
before.add(p.displayedPosition);
|
|
@@ -455,7 +455,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
g.setColor(series.color);
|
|
g.setColor(series.color);
|
|
drawBoolGraphFromList(g, after);
|
|
drawBoolGraphFromList(g, after);
|
|
// EditGraph
|
|
// EditGraph
|
|
- LinkedList<Vector2Int> middle = new LinkedList<Vector2Int>();
|
|
|
|
|
|
+ LinkedList<Vec2i> middle = new LinkedList<Vec2i>();
|
|
if (!before.isEmpty())
|
|
if (!before.isEmpty())
|
|
middle.add(before.getLast());
|
|
middle.add(before.getLast());
|
|
middle.add(editPosition);
|
|
middle.add(editPosition);
|
|
@@ -500,25 +500,25 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
* @param g2D to draw.
|
|
* @param g2D to draw.
|
|
* @param list the PositionList to draw a BoolGraph
|
|
* @param list the PositionList to draw a BoolGraph
|
|
*/
|
|
*/
|
|
- private void drawBoolGraphFromList(Graphics2D g, LinkedList<Vector2Int> list) {
|
|
|
|
|
|
+ private void drawBoolGraphFromList(Graphics2D g, LinkedList<Vec2i> list) {
|
|
if (list.size() <= 1)
|
|
if (list.size() <= 1)
|
|
return;
|
|
return;
|
|
- ListIterator<Vector2Int> iter = list.listIterator();
|
|
|
|
- LinkedList<Vector2Int> cornerPoints = new LinkedList<Vector2Int>();
|
|
|
|
- Vector2Int actual = list.getFirst();
|
|
|
|
|
|
+ ListIterator<Vec2i> iter = list.listIterator();
|
|
|
|
+ LinkedList<Vec2i> cornerPoints = new LinkedList<Vec2i>();
|
|
|
|
+ Vec2i actual = list.getFirst();
|
|
Path2D.Double path = new Path2D.Double();
|
|
Path2D.Double path = new Path2D.Double();
|
|
path.moveTo(actual.getX(), actual.getY());
|
|
path.moveTo(actual.getX(), actual.getY());
|
|
while (iter.hasNext()) {
|
|
while (iter.hasNext()) {
|
|
- Vector2Int target = iter.next();
|
|
|
|
|
|
+ Vec2i target = iter.next();
|
|
// BooleanConnection
|
|
// BooleanConnection
|
|
path.lineTo(target.getX(), actual.getY()); // line to corner
|
|
path.lineTo(target.getX(), actual.getY()); // line to corner
|
|
- cornerPoints.add(new Vector2Int(target.getX(), actual.getY())); // save corner
|
|
|
|
|
|
+ cornerPoints.add(new Vec2i(target.getX(), actual.getY())); // save corner
|
|
path.lineTo(target.getX(), target.getY()); // line to next Point
|
|
path.lineTo(target.getX(), target.getY()); // line to next Point
|
|
actual = target;
|
|
actual = target;
|
|
}
|
|
}
|
|
g.draw(path);
|
|
g.draw(path);
|
|
g.setColor(dotColor);
|
|
g.setColor(dotColor);
|
|
- for (Vector2Int p : cornerPoints) {
|
|
|
|
|
|
+ for (Vec2i p : cornerPoints) {
|
|
drawDot(g, p);
|
|
drawDot(g, p);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -535,10 +535,10 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
if (points.isEmpty())
|
|
if (points.isEmpty())
|
|
return;
|
|
return;
|
|
ListIterator<UnitGraphPoint> iter = points.listIterator();
|
|
ListIterator<UnitGraphPoint> iter = points.listIterator();
|
|
- Vector2Int actual = iter.next().displayedPosition;
|
|
|
|
|
|
+ Vec2i actual = iter.next().displayedPosition;
|
|
Path2D.Double path = this.initBezier(actual);
|
|
Path2D.Double path = this.initBezier(actual);
|
|
while (iter.hasNext()) {
|
|
while (iter.hasNext()) {
|
|
- Vector2Int target = iter.next().displayedPosition;
|
|
|
|
|
|
+ Vec2i target = iter.next().displayedPosition;
|
|
this.curveTo(path, actual, target);
|
|
this.curveTo(path, actual, target);
|
|
actual = target;
|
|
actual = target;
|
|
}
|
|
}
|
|
@@ -555,8 +555,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
* @param g2D to draw.
|
|
* @param g2D to draw.
|
|
*/
|
|
*/
|
|
private void drawDoubleGraphInEditMode(Graphics2D g, Series series) {
|
|
private void drawDoubleGraphInEditMode(Graphics2D g, Series series) {
|
|
- LinkedList<Vector2Int> before = new LinkedList<Vector2Int>();
|
|
|
|
- LinkedList<Vector2Int> after = new LinkedList<Vector2Int>();
|
|
|
|
|
|
+ LinkedList<Vec2i> before = new LinkedList<Vec2i>();
|
|
|
|
+ LinkedList<Vec2i> after = new LinkedList<Vec2i>();
|
|
for (UnitGraphPoint p : series.points) {
|
|
for (UnitGraphPoint p : series.points) {
|
|
if (p.displayedPosition.getX() < editPosition.getX())
|
|
if (p.displayedPosition.getX() < editPosition.getX())
|
|
before.add(p.displayedPosition);
|
|
before.add(p.displayedPosition);
|
|
@@ -566,7 +566,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
drawUnitGraphFromList(g, before);
|
|
drawUnitGraphFromList(g, before);
|
|
drawUnitGraphFromList(g, after);
|
|
drawUnitGraphFromList(g, after);
|
|
// EditGraph
|
|
// EditGraph
|
|
- LinkedList<Vector2Int> middle = new LinkedList<Vector2Int>();
|
|
|
|
|
|
+ LinkedList<Vec2i> middle = new LinkedList<Vec2i>();
|
|
if (!before.isEmpty())
|
|
if (!before.isEmpty())
|
|
middle.add(before.getLast());
|
|
middle.add(before.getLast());
|
|
middle.add(editPosition);
|
|
middle.add(editPosition);
|
|
@@ -586,14 +586,14 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
* @param g2D to draw.
|
|
* @param g2D to draw.
|
|
* @param list the PositionList to draw a DoubleGraph
|
|
* @param list the PositionList to draw a DoubleGraph
|
|
*/
|
|
*/
|
|
- private void drawUnitGraphFromList(Graphics2D g, LinkedList<Vector2Int> list) {
|
|
|
|
|
|
+ private void drawUnitGraphFromList(Graphics2D g, LinkedList<Vec2i> list) {
|
|
if (list.size() <= 1)
|
|
if (list.size() <= 1)
|
|
return;
|
|
return;
|
|
- ListIterator<Vector2Int> iter = list.listIterator();
|
|
|
|
- Vector2Int actual = list.getFirst();
|
|
|
|
|
|
+ ListIterator<Vec2i> iter = list.listIterator();
|
|
|
|
+ Vec2i actual = list.getFirst();
|
|
Path2D.Double path = this.initBezier(actual);
|
|
Path2D.Double path = this.initBezier(actual);
|
|
while (iter.hasNext()) {
|
|
while (iter.hasNext()) {
|
|
- Vector2Int target = iter.next();
|
|
|
|
|
|
+ Vec2i target = iter.next();
|
|
curveTo(path, actual, target);
|
|
curveTo(path, actual, target);
|
|
actual = target;
|
|
actual = target;
|
|
}
|
|
}
|
|
@@ -631,9 +631,9 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
*
|
|
*
|
|
* @param stateCurve the list of GraphPoint
|
|
* @param stateCurve the list of GraphPoint
|
|
*/
|
|
*/
|
|
- private void overrideUnitGraph(Series series, LinkedList<Vector2Float> stateCurve) {
|
|
|
|
|
|
+ private void overrideUnitGraph(Series series, LinkedList<Vec2f> stateCurve) {
|
|
series.points.clear();
|
|
series.points.clear();
|
|
- for (Vector2Float p : stateCurve) {
|
|
|
|
|
|
+ for (Vec2f p : stateCurve) {
|
|
UnitGraphPoint point = new UnitGraphPoint(p);
|
|
UnitGraphPoint point = new UnitGraphPoint(p);
|
|
point.calcDisplayedPosition(border, widthWithBorder, heightWithBorder);
|
|
point.calcDisplayedPosition(border, widthWithBorder, heightWithBorder);
|
|
series.points.add(point);
|
|
series.points.add(point);
|
|
@@ -654,7 +654,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
*/
|
|
*/
|
|
private void saveGraph() {
|
|
private void saveGraph() {
|
|
for (Series series : seriesList) {
|
|
for (Series series : seriesList) {
|
|
- LinkedList<Vector2Float> actual = series.element.getStateGraph();
|
|
|
|
|
|
+ LinkedList<Vec2f> actual = series.element.getStateGraph();
|
|
actual.clear();
|
|
actual.clear();
|
|
for (UnitGraphPoint p : series.points) {
|
|
for (UnitGraphPoint p : series.points) {
|
|
actual.add(p.getPoint());
|
|
actual.add(p.getPoint());
|
|
@@ -669,7 +669,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
*
|
|
*
|
|
* @param mPosition
|
|
* @param mPosition
|
|
*/
|
|
*/
|
|
- private void removePointNearPosition(Series series, Vector2Int mPosition) {
|
|
|
|
|
|
+ private void removePointNearPosition(Series series, Vec2i mPosition) {
|
|
ListIterator<UnitGraphPoint> iter = series.points.listIterator();
|
|
ListIterator<UnitGraphPoint> iter = series.points.listIterator();
|
|
while (iter.hasNext()) {
|
|
while (iter.hasNext()) {
|
|
if (near(mPosition, iter.next().displayedPosition, series.type)) {
|
|
if (near(mPosition, iter.next().displayedPosition, series.type)) {
|
|
@@ -680,13 +680,13 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- private void removePointsNearPosition(Vector2Int mPosition) {
|
|
|
|
|
|
+ private void removePointsNearPosition(Vec2i mPosition) {
|
|
for (Series series : seriesList) {
|
|
for (Series series : seriesList) {
|
|
removePointNearPosition(series, mPosition);
|
|
removePointNearPosition(series, mPosition);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private Optional<Series> detectSeries(Vector2Int mPosition) {
|
|
|
|
|
|
+ private Optional<Series> detectSeries(Vec2i mPosition) {
|
|
return seriesList.stream().min((a, b) -> {
|
|
return seriesList.stream().min((a, b) -> {
|
|
float minDistanceA = a.points.stream().map(point -> point.displayedPosition.getSquaredDistance(mPosition))
|
|
float minDistanceA = a.points.stream().map(point -> point.displayedPosition.getSquaredDistance(mPosition))
|
|
.min(Float::compare).get();
|
|
.min(Float::compare).get();
|
|
@@ -702,7 +702,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
*
|
|
*
|
|
* @param mPosition The Position to check.
|
|
* @param mPosition The Position to check.
|
|
*/
|
|
*/
|
|
- private EditPointType detectStartEndPoint(Series series, Vector2Int mPosition) {
|
|
|
|
|
|
+ private EditPointType detectStartEndPoint(Series series, Vec2i mPosition) {
|
|
UnitGraphPoint first = series.points.getFirst();
|
|
UnitGraphPoint first = series.points.getFirst();
|
|
UnitGraphPoint last = series.points.getLast();
|
|
UnitGraphPoint last = series.points.getLast();
|
|
if (near(mPosition, first.displayedPosition, series.type))
|
|
if (near(mPosition, first.displayedPosition, series.type))
|
|
@@ -721,7 +721,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
* @param target
|
|
* @param target
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- private boolean near(Vector2Int actual, Vector2Int target, GraphType graphType) {
|
|
|
|
|
|
+ private boolean near(Vec2i actual, Vec2i target, GraphType graphType) {
|
|
switch (graphType) {
|
|
switch (graphType) {
|
|
case boolGraph: // Distance only with X
|
|
case boolGraph: // Distance only with X
|
|
int xDis = target.getX() - actual.getX();
|
|
int xDis = target.getX() - actual.getX();
|
|
@@ -738,9 +738,9 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
*
|
|
*
|
|
* @param newPosition
|
|
* @param newPosition
|
|
*/
|
|
*/
|
|
- private void updateEditPointPosition(Vector2Int newPosition, EditPointType editPointType, GraphType graphType) {
|
|
|
|
|
|
+ private void updateEditPointPosition(Vec2i newPosition, EditPointType editPointType, GraphType graphType) {
|
|
// make it in the bounds of the UnitGraph no Point out of the Border
|
|
// make it in the bounds of the UnitGraph no Point out of the Border
|
|
- Vector2Int currentPosition = setInBounds(newPosition);
|
|
|
|
|
|
+ Vec2i currentPosition = setInBounds(newPosition);
|
|
if (editPointType != EditPointType.Normal) {
|
|
if (editPointType != EditPointType.Normal) {
|
|
attachToBorder(currentPosition, editPointType);
|
|
attachToBorder(currentPosition, editPointType);
|
|
}
|
|
}
|
|
@@ -756,7 +756,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
* @param p the Position
|
|
* @param p the Position
|
|
* @return the updated Position.
|
|
* @return the updated Position.
|
|
*/
|
|
*/
|
|
- private Vector2Int setInBounds(Vector2Int p) {
|
|
|
|
|
|
+ private Vec2i setInBounds(Vec2i p) {
|
|
p.clampX(border, border + widthWithBorder);
|
|
p.clampX(border, border + widthWithBorder);
|
|
p.clampY(border, border + heightWithBorder);
|
|
p.clampY(border, border + heightWithBorder);
|
|
return p;
|
|
return p;
|
|
@@ -768,7 +768,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
* @param p the Position
|
|
* @param p the Position
|
|
* @return the updated Position.
|
|
* @return the updated Position.
|
|
*/
|
|
*/
|
|
- private Vector2Int snapBoolean(Vector2Int p) {
|
|
|
|
|
|
+ private Vec2i snapBoolean(Vec2i p) {
|
|
if (p.getY() < border + heightWithBorder / 2) {
|
|
if (p.getY() < border + heightWithBorder / 2) {
|
|
p.setY(border);
|
|
p.setY(border);
|
|
} else {
|
|
} else {
|
|
@@ -784,7 +784,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
* @param p the Position
|
|
* @param p the Position
|
|
* @return the updated Position.
|
|
* @return the updated Position.
|
|
*/
|
|
*/
|
|
- private Vector2Int attachToBorder(Vector2Int p, EditPointType editPointType) {
|
|
|
|
|
|
+ private Vec2i attachToBorder(Vec2i p, EditPointType editPointType) {
|
|
switch (editPointType) {
|
|
switch (editPointType) {
|
|
case StartPoint:
|
|
case StartPoint:
|
|
p.setX(border);
|
|
p.setX(border);
|
|
@@ -804,11 +804,11 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
*
|
|
*
|
|
* @param pos The new UnitGraphPoints Position
|
|
* @param pos The new UnitGraphPoints Position
|
|
*/
|
|
*/
|
|
- private void insertNewGraphPoint(Series series, Vector2Int pos) {
|
|
|
|
|
|
+ private void insertNewGraphPoint(Series series, Vec2i pos) {
|
|
setInBounds(pos);
|
|
setInBounds(pos);
|
|
ListIterator<UnitGraphPoint> iter = series.points.listIterator();
|
|
ListIterator<UnitGraphPoint> iter = series.points.listIterator();
|
|
while (iter.hasNext()) {
|
|
while (iter.hasNext()) {
|
|
- Vector2Int tempPosition = iter.next().displayedPosition;
|
|
|
|
|
|
+ Vec2i tempPosition = iter.next().displayedPosition;
|
|
if (pos.getX() <= tempPosition.getX()) {
|
|
if (pos.getX() <= tempPosition.getX()) {
|
|
// previous to go back a position to make the new point before the the Position
|
|
// previous to go back a position to make the new point before the the Position
|
|
// with greater X
|
|
// with greater X
|
|
@@ -830,7 +830,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
* 0..Height
|
|
* 0..Height
|
|
* @return a UnitGraphPoint
|
|
* @return a UnitGraphPoint
|
|
*/
|
|
*/
|
|
- private UnitGraphPoint generateUnitGraphPoint(Vector2Int pos) {
|
|
|
|
|
|
+ private UnitGraphPoint generateUnitGraphPoint(Vec2i pos) {
|
|
UnitGraphPoint temp = new UnitGraphPoint((double) (pos.getX() - border) / (double) widthWithBorder,
|
|
UnitGraphPoint temp = new UnitGraphPoint((double) (pos.getX() - border) / (double) widthWithBorder,
|
|
1 - (double) (pos.getY() - border) / (double) heightWithBorder, true);
|
|
1 - (double) (pos.getY() - border) / (double) heightWithBorder, true);
|
|
temp.displayedPosition = pos;
|
|
temp.displayedPosition = pos;
|
|
@@ -843,7 +843,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
@Override
|
|
@Override
|
|
public void mouseDragged(MouseEvent e) {
|
|
public void mouseDragged(MouseEvent e) {
|
|
actualSeries.ifPresent(series -> {
|
|
actualSeries.ifPresent(series -> {
|
|
- updateEditPointPosition(new Vector2Int(e.getPoint().x, e.getPoint().y), this.editPointType, series.type);
|
|
|
|
|
|
+ updateEditPointPosition(new Vec2i(e.getPoint().x, e.getPoint().y), this.editPointType, series.type);
|
|
updateGlobalCurve();
|
|
updateGlobalCurve();
|
|
repaint();
|
|
repaint();
|
|
});
|
|
});
|
|
@@ -873,7 +873,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void mousePressed(MouseEvent e) {
|
|
public void mousePressed(MouseEvent e) {
|
|
- Vector2Int mPosition = new Vector2Int(e.getPoint().x, e.getPoint().y);
|
|
|
|
|
|
+ Vec2i mPosition = new Vec2i(e.getPoint().x, e.getPoint().y);
|
|
actualSeries = detectSeries(mPosition);
|
|
actualSeries = detectSeries(mPosition);
|
|
actualSeries.ifPresent(series -> {
|
|
actualSeries.ifPresent(series -> {
|
|
if (e.getButton() == MouseEvent.BUTTON3) {
|
|
if (e.getButton() == MouseEvent.BUTTON3) {
|