|
@@ -18,7 +18,7 @@ import java.util.ListIterator;
|
|
|
|
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JPanel;
|
|
|
|
|
|
-import classes.Position;
|
|
|
|
|
|
+import classes.Vector2dInt;
|
|
import classes.UnitGraphPoint;
|
|
import classes.UnitGraphPoint;
|
|
import interfaces.GraphEditable;
|
|
import interfaces.GraphEditable;
|
|
import interfaces.GraphEditable.Graphtype;
|
|
import interfaces.GraphEditable.Graphtype;
|
|
@@ -56,7 +56,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
private LinkedList<UnitGraphPoint> actualGraphPoints = new LinkedList<UnitGraphPoint>();
|
|
private LinkedList<UnitGraphPoint> actualGraphPoints = new LinkedList<UnitGraphPoint>();
|
|
private Graphtype actualGraphType;
|
|
private Graphtype actualGraphType;
|
|
private GraphEditable actualElement;
|
|
private GraphEditable actualElement;
|
|
- Position editPosition;
|
|
|
|
|
|
+ Vector2dInt editPosition;
|
|
boolean editMode = false;
|
|
boolean editMode = false;
|
|
private enum pointType {Normal, StartPoint, EndPoint};
|
|
private enum pointType {Normal, StartPoint, EndPoint};
|
|
pointType editPoint = pointType.Normal;
|
|
pointType editPoint = pointType.Normal;
|
|
@@ -213,8 +213,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
int lPeriod = this.getLocalPeriod();
|
|
int lPeriod = this.getLocalPeriod();
|
|
where = ((double) cur%lPeriod)/((double) lPeriod);
|
|
where = ((double) cur%lPeriod)/((double) lPeriod);
|
|
}
|
|
}
|
|
- Position oben = new Position(border + (int)(where * widthWithBorder), 0);
|
|
|
|
- Position unten = new Position(border + (int)(where * widthWithBorder), 2 * border + heightWithBorder);
|
|
|
|
|
|
+ Vector2dInt oben = new Vector2dInt(border + (int)(where * widthWithBorder), 0);
|
|
|
|
+ Vector2dInt unten = new Vector2dInt(border + (int)(where * widthWithBorder), 2 * border + heightWithBorder);
|
|
drawLine(g,oben,unten);
|
|
drawLine(g,oben,unten);
|
|
|
|
|
|
}
|
|
}
|
|
@@ -227,7 +227,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, Position start, Position end)
|
|
|
|
|
|
+ private void drawLine(Graphics2D g, Vector2dInt start, Vector2dInt end)
|
|
{
|
|
{
|
|
Path2D.Double path = new Path2D.Double();
|
|
Path2D.Double path = new Path2D.Double();
|
|
path.moveTo(start.x, start.y);
|
|
path.moveTo(start.x, start.y);
|
|
@@ -241,7 +241,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
* Initialize a Cubic BezierCurve.
|
|
* Initialize a Cubic BezierCurve.
|
|
* @param start The Position to start the Curve.
|
|
* @param start The Position to start the Curve.
|
|
*/
|
|
*/
|
|
- private Path2D.Double initBezier(Position start) {
|
|
|
|
|
|
+ private Path2D.Double initBezier(Vector2dInt 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();
|
|
@@ -256,7 +256,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, Position actual, Position target) {
|
|
|
|
|
|
+ private void curveTo(Path2D.Double path, Vector2dInt actual, Vector2dInt target) {
|
|
double mitte = (actual.x + target.x)* 0.5;
|
|
double mitte = (actual.x + target.x)* 0.5;
|
|
path.curveTo(mitte, actual.y, mitte, target.y, target.x, target.y);
|
|
path.curveTo(mitte, actual.y, mitte, target.y, target.x, target.y);
|
|
}
|
|
}
|
|
@@ -267,7 +267,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, Position p)
|
|
|
|
|
|
+ private void drawDot(Graphics2D g, Vector2dInt p)
|
|
{
|
|
{
|
|
g.fillOval(p.x -dotSize/2, p.y-dotSize/2, dotSize, dotSize);
|
|
g.fillOval(p.x -dotSize/2, p.y-dotSize/2, dotSize, dotSize);
|
|
}
|
|
}
|
|
@@ -281,17 +281,17 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
*/
|
|
*/
|
|
private void drawBoolGraph(Graphics2D g) {
|
|
private void drawBoolGraph(Graphics2D g) {
|
|
if(actualGraphPoints.size() <= 1) return;
|
|
if(actualGraphPoints.size() <= 1) return;
|
|
- LinkedList<Position> cornerPoints = new LinkedList<Position>();
|
|
|
|
|
|
+ LinkedList<Vector2dInt> cornerPoints = new LinkedList<Vector2dInt>();
|
|
ListIterator<UnitGraphPoint> iter = actualGraphPoints.listIterator();
|
|
ListIterator<UnitGraphPoint> iter = actualGraphPoints.listIterator();
|
|
- Position actual = actualGraphPoints.getFirst().displayedPosition;
|
|
|
|
|
|
+ Vector2dInt actual = actualGraphPoints.getFirst().displayedPosition;
|
|
Path2D.Double path = new Path2D.Double();
|
|
Path2D.Double path = new Path2D.Double();
|
|
path.moveTo(actual.x, actual.y);
|
|
path.moveTo(actual.x, actual.y);
|
|
while (iter.hasNext())
|
|
while (iter.hasNext())
|
|
{
|
|
{
|
|
- Position target = iter.next().displayedPosition;
|
|
|
|
|
|
+ Vector2dInt target = iter.next().displayedPosition;
|
|
//BooleanConnection
|
|
//BooleanConnection
|
|
path.lineTo(target.x, actual.y); //line to corner
|
|
path.lineTo(target.x, actual.y); //line to corner
|
|
- cornerPoints.add(new Position(target.x, actual.y)); //save corner
|
|
|
|
|
|
+ cornerPoints.add(new Vector2dInt(target.x, actual.y)); //save corner
|
|
path.lineTo(target.x, target.y); //line to next Point
|
|
path.lineTo(target.x, target.y); //line to next Point
|
|
|
|
|
|
actual = target;
|
|
actual = target;
|
|
@@ -299,7 +299,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(Position p: cornerPoints)
|
|
|
|
|
|
+ for(Vector2dInt p: cornerPoints)
|
|
{
|
|
{
|
|
drawDot(g, p);
|
|
drawDot(g, p);
|
|
}
|
|
}
|
|
@@ -312,8 +312,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
* @param g2D to draw.
|
|
* @param g2D to draw.
|
|
*/
|
|
*/
|
|
private void drawBoolGraphInEditMode(Graphics2D g) {
|
|
private void drawBoolGraphInEditMode(Graphics2D g) {
|
|
- LinkedList<Position> before = new LinkedList<Position>();
|
|
|
|
- LinkedList<Position> after = new LinkedList<Position>();
|
|
|
|
|
|
+ LinkedList<Vector2dInt> before = new LinkedList<Vector2dInt>();
|
|
|
|
+ LinkedList<Vector2dInt> after = new LinkedList<Vector2dInt>();
|
|
for(UnitGraphPoint p: actualGraphPoints)
|
|
for(UnitGraphPoint p: actualGraphPoints)
|
|
{
|
|
{
|
|
if(p.displayedPosition.x < editPosition.x)
|
|
if(p.displayedPosition.x < editPosition.x)
|
|
@@ -326,7 +326,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
g.setColor(Color.BLACK);
|
|
g.setColor(Color.BLACK);
|
|
drawBoolGraphFromList(g, after);
|
|
drawBoolGraphFromList(g, after);
|
|
//EditGraph
|
|
//EditGraph
|
|
- LinkedList<Position> middle = new LinkedList<Position>();
|
|
|
|
|
|
+ LinkedList<Vector2dInt> middle = new LinkedList<Vector2dInt>();
|
|
if(!before.isEmpty()) middle.add(before.getLast());
|
|
if(!before.isEmpty()) middle.add(before.getLast());
|
|
middle.add(editPosition);
|
|
middle.add(editPosition);
|
|
if(!after.isEmpty()) middle.add(after.getFirst());
|
|
if(!after.isEmpty()) middle.add(after.getFirst());
|
|
@@ -367,25 +367,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<Position> list) {
|
|
|
|
|
|
+ private void drawBoolGraphFromList(Graphics2D g, LinkedList<Vector2dInt> list) {
|
|
if(list.size() <= 1) return;
|
|
if(list.size() <= 1) return;
|
|
- ListIterator<Position> iter = list.listIterator();
|
|
|
|
- LinkedList<Position> cornerPoints = new LinkedList<Position>();
|
|
|
|
- Position actual = list.getFirst();
|
|
|
|
|
|
+ ListIterator<Vector2dInt> iter = list.listIterator();
|
|
|
|
+ LinkedList<Vector2dInt> cornerPoints = new LinkedList<Vector2dInt>();
|
|
|
|
+ Vector2dInt actual = list.getFirst();
|
|
Path2D.Double path = new Path2D.Double();
|
|
Path2D.Double path = new Path2D.Double();
|
|
path.moveTo(actual.x, actual.y);
|
|
path.moveTo(actual.x, actual.y);
|
|
while (iter.hasNext())
|
|
while (iter.hasNext())
|
|
{
|
|
{
|
|
- Position target = iter.next();
|
|
|
|
|
|
+ Vector2dInt target = iter.next();
|
|
//BooleanConnection
|
|
//BooleanConnection
|
|
path.lineTo(target.x, actual.y); //line to corner
|
|
path.lineTo(target.x, actual.y); //line to corner
|
|
- cornerPoints.add(new Position(target.x, actual.y)); //save corner
|
|
|
|
|
|
+ cornerPoints.add(new Vector2dInt(target.x, actual.y)); //save corner
|
|
path.lineTo(target.x, target.y); //line to next Point
|
|
path.lineTo(target.x, target.y); //line to next Point
|
|
actual = target;
|
|
actual = target;
|
|
}
|
|
}
|
|
g.draw(path);
|
|
g.draw(path);
|
|
g.setColor(dotColor);
|
|
g.setColor(dotColor);
|
|
- for(Position p: cornerPoints)
|
|
|
|
|
|
+ for(Vector2dInt p: cornerPoints)
|
|
{
|
|
{
|
|
drawDot(g, p);
|
|
drawDot(g, p);
|
|
}
|
|
}
|
|
@@ -400,11 +400,11 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
private void drawDoubleGraph(Graphics2D g) {
|
|
private void drawDoubleGraph(Graphics2D g) {
|
|
if(actualGraphPoints.isEmpty()) throw new IndexOutOfBoundsException("A Graph Without Points is not supportet jet");
|
|
if(actualGraphPoints.isEmpty()) throw new IndexOutOfBoundsException("A Graph Without Points is not supportet jet");
|
|
ListIterator<UnitGraphPoint> iter = actualGraphPoints.listIterator();
|
|
ListIterator<UnitGraphPoint> iter = actualGraphPoints.listIterator();
|
|
- Position actual = iter.next().displayedPosition;
|
|
|
|
|
|
+ Vector2dInt actual = iter.next().displayedPosition;
|
|
Path2D.Double path = this.initBezier(actual);
|
|
Path2D.Double path = this.initBezier(actual);
|
|
while (iter.hasNext())
|
|
while (iter.hasNext())
|
|
{
|
|
{
|
|
- Position target = iter.next().displayedPosition;
|
|
|
|
|
|
+ Vector2dInt target = iter.next().displayedPosition;
|
|
this.curveTo(path, actual, target);
|
|
this.curveTo(path, actual, target);
|
|
actual = target;
|
|
actual = target;
|
|
}
|
|
}
|
|
@@ -418,8 +418,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
* @param g2D to draw.
|
|
* @param g2D to draw.
|
|
*/
|
|
*/
|
|
private void drawDoubleGraphInEditMode(Graphics2D g) {
|
|
private void drawDoubleGraphInEditMode(Graphics2D g) {
|
|
- LinkedList<Position> before = new LinkedList<Position>();
|
|
|
|
- LinkedList<Position> after = new LinkedList<Position>();
|
|
|
|
|
|
+ LinkedList<Vector2dInt> before = new LinkedList<Vector2dInt>();
|
|
|
|
+ LinkedList<Vector2dInt> after = new LinkedList<Vector2dInt>();
|
|
for(UnitGraphPoint p: actualGraphPoints)
|
|
for(UnitGraphPoint p: actualGraphPoints)
|
|
{
|
|
{
|
|
if(p.displayedPosition.x < editPosition.x)
|
|
if(p.displayedPosition.x < editPosition.x)
|
|
@@ -430,7 +430,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
drawUnitGraphFromList(g, before);
|
|
drawUnitGraphFromList(g, before);
|
|
drawUnitGraphFromList(g, after);
|
|
drawUnitGraphFromList(g, after);
|
|
//EditGraph
|
|
//EditGraph
|
|
- LinkedList<Position> middle = new LinkedList<Position>();
|
|
|
|
|
|
+ LinkedList<Vector2dInt> middle = new LinkedList<Vector2dInt>();
|
|
if(!before.isEmpty()) middle.add(before.getLast());
|
|
if(!before.isEmpty()) middle.add(before.getLast());
|
|
middle.add(editPosition);
|
|
middle.add(editPosition);
|
|
if(!after.isEmpty()) middle.add(after.getFirst());
|
|
if(!after.isEmpty()) middle.add(after.getFirst());
|
|
@@ -446,14 +446,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<Position> list) {
|
|
|
|
|
|
+ private void drawUnitGraphFromList(Graphics2D g, LinkedList<Vector2dInt> list) {
|
|
if(list.size() <= 1) return;
|
|
if(list.size() <= 1) return;
|
|
- ListIterator<Position> iter = list.listIterator();
|
|
|
|
- Position actual = list.getFirst();
|
|
|
|
|
|
+ ListIterator<Vector2dInt> iter = list.listIterator();
|
|
|
|
+ Vector2dInt actual = list.getFirst();
|
|
Path2D.Double path = this.initBezier(actual);
|
|
Path2D.Double path = this.initBezier(actual);
|
|
while (iter.hasNext())
|
|
while (iter.hasNext())
|
|
{
|
|
{
|
|
- Position target = iter.next();
|
|
|
|
|
|
+ Vector2dInt target = iter.next();
|
|
curveTo(path, actual, target);
|
|
curveTo(path, actual, target);
|
|
actual = target;
|
|
actual = target;
|
|
}
|
|
}
|
|
@@ -509,7 +509,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
* Remove a UnitGraphPoint from the UnitGraphPoint list ({@link #actualGraphPoints} when its near a given Position.
|
|
* Remove a UnitGraphPoint from the UnitGraphPoint list ({@link #actualGraphPoints} when its near a given Position.
|
|
* @param mPosition
|
|
* @param mPosition
|
|
*/
|
|
*/
|
|
- private void removePointNearPosition(Position mPosition) {
|
|
|
|
|
|
+ private void removePointNearPosition(Vector2dInt mPosition) {
|
|
ListIterator<UnitGraphPoint> iter = actualGraphPoints.listIterator();
|
|
ListIterator<UnitGraphPoint> iter = actualGraphPoints.listIterator();
|
|
while (iter.hasNext())
|
|
while (iter.hasNext())
|
|
{
|
|
{
|
|
@@ -526,7 +526,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
* Determine if the Point is a StartPoint , EndPoint or a NormalPoint a.k.a. in between Points.
|
|
* Determine if the Point is a StartPoint , EndPoint or a NormalPoint a.k.a. in between Points.
|
|
* @param mPosition The Position to check.
|
|
* @param mPosition The Position to check.
|
|
*/
|
|
*/
|
|
- private void detectStartEndPoint(Position mPosition)
|
|
|
|
|
|
+ private void detectStartEndPoint(Vector2dInt mPosition)
|
|
{
|
|
{
|
|
UnitGraphPoint first = actualGraphPoints.getFirst();
|
|
UnitGraphPoint first = actualGraphPoints.getFirst();
|
|
UnitGraphPoint last = actualGraphPoints.getLast();
|
|
UnitGraphPoint last = actualGraphPoints.getLast();
|
|
@@ -541,7 +541,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
* @param target
|
|
* @param target
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- private boolean near(Position actual, Position target) {
|
|
|
|
|
|
+ private boolean near(Vector2dInt actual, Vector2dInt target) {
|
|
switch(actualGraphType)
|
|
switch(actualGraphType)
|
|
{
|
|
{
|
|
case boolGraph: //Distance only with X
|
|
case boolGraph: //Distance only with X
|
|
@@ -558,9 +558,9 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
* When the Mouse Drag a Point it updates each time the position.
|
|
* When the Mouse Drag a Point it updates each time the position.
|
|
* @param newPosition
|
|
* @param newPosition
|
|
*/
|
|
*/
|
|
- private void updateEditPointPosition(Position newPosition) {
|
|
|
|
|
|
+ private void updateEditPointPosition(Vector2dInt newPosition) {
|
|
//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
|
|
- Position currentPosition = setInBounds(newPosition);
|
|
|
|
|
|
+ Vector2dInt currentPosition = setInBounds(newPosition);
|
|
if(editPoint != pointType.Normal) attachToBorder(currentPosition);
|
|
if(editPoint != pointType.Normal) attachToBorder(currentPosition);
|
|
if(actualGraphType == Graphtype.boolGraph) snapBoolean(currentPosition);
|
|
if(actualGraphType == Graphtype.boolGraph) snapBoolean(currentPosition);
|
|
this.editPosition = currentPosition;
|
|
this.editPosition = currentPosition;
|
|
@@ -572,7 +572,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 Position setInBounds(Position p) {
|
|
|
|
|
|
+ private Vector2dInt setInBounds(Vector2dInt 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;
|
|
@@ -585,7 +585,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 Position snapBoolean(Position p)
|
|
|
|
|
|
+ private Vector2dInt snapBoolean(Vector2dInt p)
|
|
{
|
|
{
|
|
if (p.y < border + heightWithBorder / 2) {
|
|
if (p.y < border + heightWithBorder / 2) {
|
|
p.y = border;
|
|
p.y = border;
|
|
@@ -601,7 +601,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 Position attachToBorder(Position p)
|
|
|
|
|
|
+ private Vector2dInt attachToBorder(Vector2dInt p)
|
|
{
|
|
{
|
|
switch(editPoint)
|
|
switch(editPoint)
|
|
{
|
|
{
|
|
@@ -621,13 +621,13 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
* Its sorted based on the xValues.
|
|
* Its sorted based on the xValues.
|
|
* @param pos The new UnitGraphPoints Position
|
|
* @param pos The new UnitGraphPoints Position
|
|
*/
|
|
*/
|
|
- private void insertNewGraphPoint(Position pos)
|
|
|
|
|
|
+ private void insertNewGraphPoint(Vector2dInt pos)
|
|
{
|
|
{
|
|
setInBounds(pos);
|
|
setInBounds(pos);
|
|
ListIterator<UnitGraphPoint> iter2 = actualGraphPoints.listIterator();
|
|
ListIterator<UnitGraphPoint> iter2 = actualGraphPoints.listIterator();
|
|
while (iter2.hasNext())
|
|
while (iter2.hasNext())
|
|
{
|
|
{
|
|
- Position tempPosition = iter2.next().displayedPosition;
|
|
|
|
|
|
+ Vector2dInt tempPosition = iter2.next().displayedPosition;
|
|
if(pos.x <= tempPosition.x)
|
|
if(pos.x <= tempPosition.x)
|
|
{
|
|
{
|
|
//previous to go back a position to make the new point before the the Position with greater X
|
|
//previous to go back a position to make the new point before the the Position with greater X
|
|
@@ -646,7 +646,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
* @param pos the normal pos with xValues from 0..Width and yValues from 0..Height
|
|
* @param pos the normal pos with xValues from 0..Width and yValues from 0..Height
|
|
* @return a UnitGraphPoint
|
|
* @return a UnitGraphPoint
|
|
*/
|
|
*/
|
|
- private UnitGraphPoint generateUnitGraphPoint(Position pos) {
|
|
|
|
|
|
+ private UnitGraphPoint generateUnitGraphPoint(Vector2dInt pos) {
|
|
UnitGraphPoint temp = new UnitGraphPoint((double) (pos.x - border) / (double) widthWithBorder,
|
|
UnitGraphPoint temp = new UnitGraphPoint((double) (pos.x - border) / (double) widthWithBorder,
|
|
1 - (double) (pos.y - border) / (double) heightWithBorder, true);
|
|
1 - (double) (pos.y - border) / (double) heightWithBorder, true);
|
|
temp.displayedPosition = pos;
|
|
temp.displayedPosition = pos;
|
|
@@ -658,7 +658,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void mouseDragged(MouseEvent e) {
|
|
public void mouseDragged(MouseEvent e) {
|
|
- updateEditPointPosition(new Position(e.getPoint()));
|
|
|
|
|
|
+ updateEditPointPosition(new Vector2dInt(e.getPoint()));
|
|
repaint();
|
|
repaint();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -685,7 +685,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void mousePressed(MouseEvent e) {
|
|
public void mousePressed(MouseEvent e) {
|
|
- Position mPosition = new Position(e.getPoint());
|
|
|
|
|
|
+ Vector2dInt mPosition = new Vector2dInt(e.getPoint());
|
|
if (e.getButton() == MouseEvent.BUTTON3) {
|
|
if (e.getButton() == MouseEvent.BUTTON3) {
|
|
// RightMouseButtonEvent
|
|
// RightMouseButtonEvent
|
|
detectStartEndPoint(mPosition);
|
|
detectStartEndPoint(mPosition);
|