|
@@ -84,9 +84,9 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
// Cps objecte aus dem border links schieben
|
|
// Cps objecte aus dem border links schieben
|
|
upperNode.setLeftBorder(/*(int) (50 + scalediv20 + scalediv20 + 10)*/ 0);
|
|
upperNode.setLeftBorder(/*(int) (50 + scalediv20 + scalediv20 + 10)*/ 0);
|
|
for (AbstractCanvasObject cps : upperNode.getNodes()) {
|
|
for (AbstractCanvasObject cps : upperNode.getNodes()) {
|
|
- if (cps.getPosition().x < model.getScaleDiv2() + upperNode.getLeftBorder() + 5) {
|
|
|
|
|
|
+ if (cps.getPosition().getX() < model.getScaleDiv2() + upperNode.getLeftBorder() + 5) {
|
|
cps.setPosition(
|
|
cps.setPosition(
|
|
- new Vector2dInt(upperNode.getLeftBorder() + 5 + model.getScaleDiv2(), cps.getPosition().y));
|
|
|
|
|
|
+ new Vector2dInt(upperNode.getLeftBorder() + 5 + model.getScaleDiv2(), cps.getPosition().getY()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -126,27 +126,23 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
animCps = new ArrayList<>();
|
|
animCps = new ArrayList<>();
|
|
for (AbstractCanvasObject cps : model.getSelectedCpsObjects()) {
|
|
for (AbstractCanvasObject cps : model.getSelectedCpsObjects()) {
|
|
animCps.add(cps); // add to animation Cps ArrayList
|
|
animCps.add(cps); // add to animation Cps ArrayList
|
|
- unPos.x += cps.getPosition().x;
|
|
|
|
- unPos.y += cps.getPosition().y;
|
|
|
|
|
|
+ unPos = unPos.add(cps.getPosition());
|
|
}
|
|
}
|
|
- unPos.x /= animCps.size();
|
|
|
|
- unPos.y /= animCps.size();
|
|
|
|
|
|
+ unPos = unPos.divide(animCps.size());
|
|
|
|
|
|
// save old Position
|
|
// save old Position
|
|
savePos = new ArrayList<>();
|
|
savePos = new ArrayList<>();
|
|
for (int i = 0; i < animCps.size(); i++) {
|
|
for (int i = 0; i < animCps.size(); i++) {
|
|
- savePos.add(new Vector2dInt(0, 0));
|
|
|
|
- savePos.get(i).x = animCps.get(i).getPosition().x;
|
|
|
|
- savePos.get(i).y = animCps.get(i).getPosition().y;
|
|
|
|
|
|
+ savePos.add(animCps.get(i).getPosition().clone());
|
|
}
|
|
}
|
|
|
|
|
|
animT = new javax.swing.Timer(animDelay, actionEvent1 -> {
|
|
animT = new javax.swing.Timer(animDelay, actionEvent1 -> {
|
|
if (animDuration - animDelay > 0 && animCps.size() > 1) {
|
|
if (animDuration - animDelay > 0 && animCps.size() > 1) {
|
|
for (AbstractCanvasObject currentAnimCps : animCps) {
|
|
for (AbstractCanvasObject currentAnimCps : animCps) {
|
|
- double x1 = currentAnimCps.getPosition().x - unPos.x;
|
|
|
|
- double y1 = currentAnimCps.getPosition().y - unPos.y;
|
|
|
|
- currentAnimCps.getPosition().x -= x1 / animSteps;
|
|
|
|
- currentAnimCps.getPosition().y -= y1 / animSteps;
|
|
|
|
|
|
+ Vector2dInt pos = currentAnimCps.getPosition();
|
|
|
|
+ Vector2dInt difference = pos.subtract(unPos);
|
|
|
|
+ Vector2dInt result = pos.subtract(difference.divide(animSteps));
|
|
|
|
+ pos.set(result);
|
|
}
|
|
}
|
|
repaint();
|
|
repaint();
|
|
animDuration -= animDelay;
|
|
animDuration -= animDelay;
|
|
@@ -156,8 +152,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
animSteps = animDuration / animDelay;
|
|
animSteps = animDuration / animDelay;
|
|
animT.stop();
|
|
animT.stop();
|
|
for (int i = 0; i < animCps.size(); i++) {
|
|
for (int i = 0; i < animCps.size(); i++) {
|
|
- animCps.get(i).getPosition().x = savePos.get(i).x;
|
|
|
|
- animCps.get(i).getPosition().y = savePos.get(i).y;
|
|
|
|
|
|
+ animCps.get(i).getPosition().set(savePos.get(i));
|
|
}
|
|
}
|
|
controller.addUpperNode("GroupNode", upperNode, model.getSelectedCpsObjects());
|
|
controller.addUpperNode("GroupNode", upperNode, model.getSelectedCpsObjects());
|
|
controller.calculateStateAndVisualForCurrentTimeStep();
|
|
controller.calculateStateAndVisualForCurrentTimeStep();
|
|
@@ -176,24 +171,19 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
controller.ungroupGroupNode((GroupNode) tempCps, upperNode);
|
|
controller.ungroupGroupNode((GroupNode) tempCps, upperNode);
|
|
|
|
|
|
for (int i = 0; i < animCps.size(); i++) {
|
|
for (int i = 0; i < animCps.size(); i++) {
|
|
- savePos.add(new Vector2dInt(0, 0));
|
|
|
|
- savePos.get(i).x = animCps.get(i).getPosition().x;
|
|
|
|
- savePos.get(i).y = animCps.get(i).getPosition().y;
|
|
|
|
|
|
+ savePos.add(animCps.get(i).getPosition().clone());
|
|
}
|
|
}
|
|
for (AbstractCanvasObject cps : animCps) {
|
|
for (AbstractCanvasObject cps : animCps) {
|
|
- int x = tempCps.getPosition().x;
|
|
|
|
- int y = tempCps.getPosition().y;
|
|
|
|
-
|
|
|
|
- cps.setPosition(new Vector2dInt(x, y));
|
|
|
|
|
|
+ cps.setPosition(tempCps.getPosition().clone());
|
|
}
|
|
}
|
|
|
|
|
|
animT = new javax.swing.Timer(animDelay, actionEvent1 -> {
|
|
animT = new javax.swing.Timer(animDelay, actionEvent1 -> {
|
|
if (animDuration - animDelay >= 0) {
|
|
if (animDuration - animDelay >= 0) {
|
|
for (int i = 0; i < animCps.size(); i++) {
|
|
for (int i = 0; i < animCps.size(); i++) {
|
|
- double x1 = animCps.get(i).getPosition().x - savePos.get(i).x;
|
|
|
|
- double y1 = animCps.get(i).getPosition().y - savePos.get(i).y;
|
|
|
|
- animCps.get(i).getPosition().x -= x1 / animSteps;
|
|
|
|
- animCps.get(i).getPosition().y -= y1 / animSteps;
|
|
|
|
|
|
+ Vector2dInt pos = animCps.get(i).getPosition();
|
|
|
|
+ Vector2dInt difference = pos.subtract(savePos.get(i));
|
|
|
|
+ Vector2dInt result = pos.subtract(difference.divide(animSteps));
|
|
|
|
+ pos.set(result);
|
|
}
|
|
}
|
|
repaint();
|
|
repaint();
|
|
animDuration -= animDelay;
|
|
animDuration -= animDelay;
|
|
@@ -203,8 +193,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
animSteps = animDuration / animDelay;
|
|
animSteps = animDuration / animDelay;
|
|
animT.stop();
|
|
animT.stop();
|
|
for (int i = 0; i < animCps.size(); i++) {
|
|
for (int i = 0; i < animCps.size(); i++) {
|
|
- animCps.get(i).getPosition().x = savePos.get(i).x;
|
|
|
|
- animCps.get(i).getPosition().y = savePos.get(i).y;
|
|
|
|
|
|
+ animCps.get(i).getPosition().set(savePos.get(i));
|
|
}
|
|
}
|
|
|
|
|
|
controller.calculateStateAndVisualForCurrentTimeStep();
|
|
controller.calculateStateAndVisualForCurrentTimeStep();
|
|
@@ -308,13 +297,13 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
Vector2dInt pos = decoratedHolonObject.getModel().getPosition();
|
|
Vector2dInt pos = decoratedHolonObject.getModel().getPosition();
|
|
Color statecolor = getStateColor(decoratedHolonObject.getState());
|
|
Color statecolor = getStateColor(decoratedHolonObject.getState());
|
|
g.setColor(statecolor);
|
|
g.setColor(statecolor);
|
|
- g.fillRect(pos.x - controller.getScaleDiv2(), pos.y - controller.getScaleDiv2(), controller.getScale(), controller.getScale());
|
|
|
|
|
|
+ g.fillRect(pos.getX() - controller.getScaleDiv2(), pos.getY() - controller.getScaleDiv2(), controller.getScale(), controller.getScale());
|
|
drawCanvasObject(g, decoratedHolonObject.getModel().getImage(), pos);
|
|
drawCanvasObject(g, decoratedHolonObject.getModel().getImage(), pos);
|
|
}
|
|
}
|
|
private void drawCanvasObjectString(Graphics2D g, Vector2dInt posOfCanvasObject, float energy) {
|
|
private void drawCanvasObjectString(Graphics2D g, Vector2dInt posOfCanvasObject, float energy) {
|
|
g.setColor(Color.BLACK);
|
|
g.setColor(Color.BLACK);
|
|
g.setFont(new Font("TimesNewRoman", Font.PLAIN, (int) (controller.getScale() / 4f) ));
|
|
g.setFont(new Font("TimesNewRoman", Font.PLAIN, (int) (controller.getScale() / 4f) ));
|
|
- g.drawString((energy > 0)? "+" + Float.toString(energy): Float.toString(energy), posOfCanvasObject.x - controller.getScaleDiv2(), posOfCanvasObject.y - controller.getScaleDiv2() - 1);
|
|
|
|
|
|
+ g.drawString((energy > 0)? "+" + Float.toString(energy): Float.toString(energy), posOfCanvasObject.getX() - controller.getScaleDiv2(), posOfCanvasObject.getY() - controller.getScaleDiv2() - 1);
|
|
}
|
|
}
|
|
private void paintConsumer(Graphics2D g, Consumer con){
|
|
private void paintConsumer(Graphics2D g, Consumer con){
|
|
paintCanvasObject(g, con);
|
|
paintCanvasObject(g, con);
|
|
@@ -328,8 +317,8 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
|
|
|
|
private void drawCanvasObject(Graphics2D g, String Image, Vector2dInt pos) {
|
|
private void drawCanvasObject(Graphics2D g, String Image, Vector2dInt pos) {
|
|
g.drawImage(ImageImport.loadImage(Image, controller.getScale(), controller.getScale()) ,
|
|
g.drawImage(ImageImport.loadImage(Image, controller.getScale(), controller.getScale()) ,
|
|
- pos.x - controller.getScaleDiv2(),
|
|
|
|
- pos.y - controller.getScaleDiv2(),
|
|
|
|
|
|
+ pos.getX() - controller.getScaleDiv2(),
|
|
|
|
+ pos.getY() - controller.getScaleDiv2(),
|
|
controller.getScale(), controller.getScale() , null);
|
|
controller.getScale(), controller.getScale() , null);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -353,10 +342,10 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
if(isSelected){
|
|
if(isSelected){
|
|
g.setColor(Color.lightGray);
|
|
g.setColor(Color.lightGray);
|
|
}
|
|
}
|
|
- g.drawLine(start.x, start.y, end.x, end.y);
|
|
|
|
- Vector2dInt middle = new Vector2dInt((start.x + end.x) / 2, (start.y + end.y) / 2);
|
|
|
|
|
|
+ g.drawLine(start.getX(), start.getY(), end.getX(), end.getY());
|
|
|
|
+ Vector2dInt middle = new Vector2dInt((start.getX() + end.getX()) / 2, (start.getY() + end.getY()) / 2);
|
|
g.setFont(new Font("TimesRoman", Font.PLAIN, Math.max((int) (controller.getScale() / 3.5f), 10) ));
|
|
g.setFont(new Font("TimesRoman", Font.PLAIN, Math.max((int) (controller.getScale() / 3.5f), 10) ));
|
|
- g.drawString(currentEnergy + "/" + (unlimited?"\u221E":capacity) , middle.x, middle.y);
|
|
|
|
|
|
+ g.drawString(currentEnergy + "/" + (unlimited?"\u221E":capacity) , middle.getX(), middle.getY());
|
|
}
|
|
}
|
|
private void paintSwitch(Graphics2D g, DecoratedSwitch dSwitch)
|
|
private void paintSwitch(Graphics2D g, DecoratedSwitch dSwitch)
|
|
{
|
|
{
|
|
@@ -365,7 +354,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
private void paintGroupNode(Graphics2D g, DecoratedGroupNode dGroupNode) {
|
|
private void paintGroupNode(Graphics2D g, DecoratedGroupNode dGroupNode) {
|
|
Vector2dInt pos = dGroupNode.getModel().getPosition();
|
|
Vector2dInt pos = dGroupNode.getModel().getPosition();
|
|
g.setColor(Color.lightGray);
|
|
g.setColor(Color.lightGray);
|
|
- g.fillRect(pos.x - controller.getScaleDiv2(), pos.y - controller.getScaleDiv2(), controller.getScale(), controller.getScale());
|
|
|
|
|
|
+ g.fillRect(pos.getX() - controller.getScaleDiv2(), pos.getY() - controller.getScaleDiv2(), controller.getScale(), controller.getScale());
|
|
drawCanvasObject(g, "/Images/upper_node.png" , pos);
|
|
drawCanvasObject(g, "/Images/upper_node.png" , pos);
|
|
paintGroupNodeBar(g, dGroupNode, pos);
|
|
paintGroupNodeBar(g, dGroupNode, pos);
|
|
}
|
|
}
|
|
@@ -374,7 +363,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
int barWidth = (int) (controller.getScale());
|
|
int barWidth = (int) (controller.getScale());
|
|
int barHeight = (int) (controller.getScale() / 5);
|
|
int barHeight = (int) (controller.getScale() / 5);
|
|
g.setColor(Color.WHITE);
|
|
g.setColor(Color.WHITE);
|
|
- g.fillRect(pos.x - controller.getScaleDiv2(), pos.y + controller.getScaleDiv2() - 1, (int) barWidth, barHeight);
|
|
|
|
|
|
+ g.fillRect(pos.getX() - controller.getScaleDiv2(), pos.getY() + controller.getScaleDiv2() - 1, (int) barWidth, barHeight);
|
|
float[] percentages = getGroupNodeBarPercentages(dGroupNode);
|
|
float[] percentages = getGroupNodeBarPercentages(dGroupNode);
|
|
Color[] colors = new Color[6];
|
|
Color[] colors = new Color[6];
|
|
colors[0] = getStateColor(HolonObjectState.PRODUCER);
|
|
colors[0] = getStateColor(HolonObjectState.PRODUCER);
|
|
@@ -386,13 +375,13 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
|
|
|
|
for(int i = 5; i>=0; i--) {
|
|
for(int i = 5; i>=0; i--) {
|
|
g.setColor(colors[i]);
|
|
g.setColor(colors[i]);
|
|
- g.fillRect(pos.x - controller.getScaleDiv2(), pos.y + controller.getScaleDiv2() - 1, (int) (barWidth * percentages[i] - 1), barHeight);
|
|
|
|
|
|
+ g.fillRect(pos.getX() - controller.getScaleDiv2(), pos.getY() + controller.getScaleDiv2() - 1, (int) (barWidth * percentages[i] - 1), barHeight);
|
|
}
|
|
}
|
|
// g.setColor(color);
|
|
// g.setColor(color);
|
|
-// g.fillRect(pos.x - controller.getScaleDiv2(), pos.y + controller.getScaleDiv2() - 1, (int) (barWidth * (percentage < 1 ? percentage : 1.0f) - 1), barHeight);
|
|
|
|
|
|
+// g.fillRect(pos.getX() - controller.getScaleDiv2(), pos.getY() + controller.getScaleDiv2() - 1, (int) (barWidth * (percentage < 1 ? percentage : 1.0f) - 1), barHeight);
|
|
g.setColor(Color.BLACK);
|
|
g.setColor(Color.BLACK);
|
|
g.setStroke(new BasicStroke(1));
|
|
g.setStroke(new BasicStroke(1));
|
|
- g.drawRect(pos.x - controller.getScaleDiv2(), pos.y + controller.getScaleDiv2() - 1, barWidth - 1 , barHeight);
|
|
|
|
|
|
+ g.drawRect(pos.getX() - controller.getScaleDiv2(), pos.getY() + controller.getScaleDiv2() - 1, barWidth - 1 , barHeight);
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
* HardCoded Stuff dont try at Home ;)
|
|
* HardCoded Stuff dont try at Home ;)
|
|
@@ -440,23 +429,23 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
switch(eCable.getState()) {
|
|
switch(eCable.getState()) {
|
|
case DOWN:
|
|
case DOWN:
|
|
case DOWNDOWN:
|
|
case DOWNDOWN:
|
|
- g.drawLine(start.x, start.y, end.x, end.y);
|
|
|
|
- Vector2dInt middle = new Vector2dInt((start.x + end.x) / 2, (start.y + end.y) / 2);
|
|
|
|
|
|
+ g.drawLine(start.getX(), start.getY(), end.getX(), end.getY());
|
|
|
|
+ Vector2dInt middle = new Vector2dInt((start.getX() + end.getX()) / 2, (start.getY() + end.getY()) / 2);
|
|
g.setFont(new Font("TimesRoman", Font.PLAIN, Math.max((int) (controller.getScale() / 3.5f), 10) ));
|
|
g.setFont(new Font("TimesRoman", Font.PLAIN, Math.max((int) (controller.getScale() / 3.5f), 10) ));
|
|
- g.drawString(currentEnergy + "/" + (unlimited?"\u221E":capacity) , middle.x, middle.y);
|
|
|
|
|
|
+ g.drawString(currentEnergy + "/" + (unlimited?"\u221E":capacity) , middle.getX(), middle.getY());
|
|
break;
|
|
break;
|
|
case DOWNUP:
|
|
case DOWNUP:
|
|
case UP:
|
|
case UP:
|
|
- Vector2dFloat vStart = new Vector2dFloat(start.x, start.y);
|
|
|
|
- Vector2dFloat vEnd = new Vector2dFloat(end.x, end.y);
|
|
|
|
|
|
+ Vector2dFloat vStart = new Vector2dFloat(start.getX(), start.getY());
|
|
|
|
+ Vector2dFloat vEnd = new Vector2dFloat(end.getX(), end.getY());
|
|
float stretchFactor = 4 * model.getScale();
|
|
float stretchFactor = 4 * model.getScale();
|
|
stretchFactor = (stretchFactor > vStart.getDistance(vEnd))? vStart.getDistance(vEnd) : stretchFactor;
|
|
stretchFactor = (stretchFactor > vStart.getDistance(vEnd))? vStart.getDistance(vEnd) : stretchFactor;
|
|
Vector2dFloat vPosition = vStart.add((vEnd.subtract(vStart)).normalize().multiply(stretchFactor));
|
|
Vector2dFloat vPosition = vStart.add((vEnd.subtract(vStart)).normalize().multiply(stretchFactor));
|
|
Vector2dInt result = new Vector2dInt(Math.round(vPosition.getX()),Math.round(vPosition.getY()));
|
|
Vector2dInt result = new Vector2dInt(Math.round(vPosition.getX()),Math.round(vPosition.getY()));
|
|
- g.drawLine(start.x, start.y, result.x, result.y);
|
|
|
|
- Vector2dInt middle1 = new Vector2dInt((start.x +result.x) / 2, (start.y + +result.y) / 2);
|
|
|
|
|
|
+ g.drawLine(start.getX(), start.getY(), result.getX(), result.getY());
|
|
|
|
+ Vector2dInt middle1 = new Vector2dInt((start.getX() +result.getX()) / 2, (start.getY() + +result.getY()) / 2);
|
|
g.setFont(new Font("TimesRoman", Font.PLAIN, Math.max((int) (controller.getScale() / 3.5f), 10) ));
|
|
g.setFont(new Font("TimesRoman", Font.PLAIN, Math.max((int) (controller.getScale() / 3.5f), 10) ));
|
|
- g.drawString(currentEnergy + "/" + (unlimited?"\u221E":capacity) , middle1.x, middle1.y);
|
|
|
|
|
|
+ g.drawString(currentEnergy + "/" + (unlimited?"\u221E":capacity) , middle1.getX(), middle1.getY());
|
|
drawCanvasObject(g, "/Images/arrowUp.png" , result);
|
|
drawCanvasObject(g, "/Images/arrowUp.png" , result);
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
@@ -469,17 +458,17 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
int barWidth = (int) (controller.getScale());
|
|
int barWidth = (int) (controller.getScale());
|
|
int barHeight = (int) (controller.getScale() / 5);
|
|
int barHeight = (int) (controller.getScale() / 5);
|
|
g.setColor(Color.WHITE);
|
|
g.setColor(Color.WHITE);
|
|
- g.fillRect(pos.x - controller.getScaleDiv2(), pos.y + controller.getScaleDiv2() - 1, (int) barWidth, barHeight);
|
|
|
|
|
|
+ g.fillRect(pos.getX() - controller.getScaleDiv2(), pos.getY() + controller.getScaleDiv2() - 1, (int) barWidth, barHeight);
|
|
g.setColor(color);
|
|
g.setColor(color);
|
|
- g.fillRect(pos.x - controller.getScaleDiv2(), pos.y + controller.getScaleDiv2() - 1, (int) (barWidth * (percentage < 1 ? percentage : 1.0f) - 1), barHeight);
|
|
|
|
|
|
+ g.fillRect(pos.getX() - controller.getScaleDiv2(), pos.getY() + controller.getScaleDiv2() - 1, (int) (barWidth * (percentage < 1 ? percentage : 1.0f) - 1), barHeight);
|
|
g.setColor(Color.BLACK);
|
|
g.setColor(Color.BLACK);
|
|
g.setStroke(new BasicStroke(1));
|
|
g.setStroke(new BasicStroke(1));
|
|
- g.drawRect(pos.x - controller.getScaleDiv2(), pos.y + controller.getScaleDiv2() - 1, barWidth - 1 , barHeight);
|
|
|
|
|
|
+ g.drawRect(pos.getX() - controller.getScaleDiv2(), pos.getY() + controller.getScaleDiv2() - 1, barWidth - 1 , barHeight);
|
|
g.setFont(new Font("TimesNewRoman", Font.PLAIN, (int) (barHeight * 1.5) - 2));
|
|
g.setFont(new Font("TimesNewRoman", Font.PLAIN, (int) (barHeight * 1.5) - 2));
|
|
String percentageString = (Math.round((percentage * 100))) + "%";
|
|
String percentageString = (Math.round((percentage * 100))) + "%";
|
|
int stringWidth = (int) g.getFontMetrics().getStringBounds(percentageString, g).getWidth();
|
|
int stringWidth = (int) g.getFontMetrics().getStringBounds(percentageString, g).getWidth();
|
|
if(percentage > 1.0f) g.setColor(Color.WHITE); //Just to see better on purple
|
|
if(percentage > 1.0f) g.setColor(Color.WHITE); //Just to see better on purple
|
|
- g.drawString(percentageString, pos.x + 1 - stringWidth / 2, pos.y + controller.getScaleDiv2() - 1+ barHeight);
|
|
|
|
|
|
+ g.drawString(percentageString, pos.getX() + 1 - stringWidth / 2, pos.getY() + controller.getScaleDiv2() - 1+ barHeight);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -513,7 +502,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
if (drawEdge) {
|
|
if (drawEdge) {
|
|
g2d.setColor(Color.BLACK);
|
|
g2d.setColor(Color.BLACK);
|
|
g2d.setStroke(new BasicStroke(1));
|
|
g2d.setStroke(new BasicStroke(1));
|
|
- g2d.drawLine(tempCps.getPosition().x, tempCps.getPosition().y, x, y);
|
|
|
|
|
|
+ g2d.drawLine(tempCps.getPosition().getX(), tempCps.getPosition().getY(), x, y);
|
|
}
|
|
}
|
|
//<--
|
|
//<--
|
|
//SelectedCable
|
|
//SelectedCable
|
|
@@ -570,18 +559,18 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
if(aCps instanceof Node) {
|
|
if(aCps instanceof Node) {
|
|
Vector2dInt pos = aCps.getPosition();
|
|
Vector2dInt pos = aCps.getPosition();
|
|
g2d.setColor(transparentGrey);
|
|
g2d.setColor(transparentGrey);
|
|
- g2d.fillOval(pos.x - (int) (controller.getScaleDiv2()), pos.y - (int) (controller.getScaleDiv2()), controller.getScale(), controller.getScale());
|
|
|
|
|
|
+ g2d.fillOval(pos.getX() - (int) (controller.getScaleDiv2()), pos.getY() - (int) (controller.getScaleDiv2()), controller.getScale(), controller.getScale());
|
|
g2d.setColor(Color.LIGHT_GRAY);
|
|
g2d.setColor(Color.LIGHT_GRAY);
|
|
g2d.setStroke(new BasicStroke(2));
|
|
g2d.setStroke(new BasicStroke(2));
|
|
- g2d.drawOval(pos.x - (int) (controller.getScaleDiv2()), pos.y - (int) (controller.getScaleDiv2()), controller.getScale(), controller.getScale());
|
|
|
|
|
|
+ g2d.drawOval(pos.getX() - (int) (controller.getScaleDiv2()), pos.getY() - (int) (controller.getScaleDiv2()), controller.getScale(), controller.getScale());
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
Vector2dInt pos = aCps.getPosition();
|
|
Vector2dInt pos = aCps.getPosition();
|
|
g2d.setColor(transparentGrey);
|
|
g2d.setColor(transparentGrey);
|
|
- g2d.fillRect(pos.x - (int) (controller.getScaleDiv2()* 1.5f), pos.y - (int) (controller.getScaleDiv2()* 1.5f), (int) (controller.getScale()* 1.5f) , (int) (controller.getScale()* 1.5f));
|
|
|
|
|
|
+ g2d.fillRect(pos.getX() - (int) (controller.getScaleDiv2()* 1.5f), pos.getY() - (int) (controller.getScaleDiv2()* 1.5f), (int) (controller.getScale()* 1.5f) , (int) (controller.getScale()* 1.5f));
|
|
g2d.setColor(Color.LIGHT_GRAY);
|
|
g2d.setColor(Color.LIGHT_GRAY);
|
|
g2d.setStroke(new BasicStroke(2));
|
|
g2d.setStroke(new BasicStroke(2));
|
|
- g2d.drawRect(pos.x - (int) (controller.getScaleDiv2()* 1.5f), pos.y - (int) (controller.getScaleDiv2()* 1.5f), (int) (controller.getScale()* 1.5f) , (int) (controller.getScale()* 1.5f));
|
|
|
|
|
|
+ g2d.drawRect(pos.getX() - (int) (controller.getScaleDiv2()* 1.5f), pos.getY() - (int) (controller.getScaleDiv2()* 1.5f), (int) (controller.getScale()* 1.5f) , (int) (controller.getScale()* 1.5f));
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -590,8 +579,8 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
g2d.setColor(Color.RED);
|
|
g2d.setColor(Color.RED);
|
|
Vector2dInt pos = mayBeReplaced.getPosition();
|
|
Vector2dInt pos = mayBeReplaced.getPosition();
|
|
g.drawImage(ImageImport.loadImage("/Images/replace.png") ,
|
|
g.drawImage(ImageImport.loadImage("/Images/replace.png") ,
|
|
- pos.x + controller.getScaleDiv2(),
|
|
|
|
- pos.y - controller.getScale(),
|
|
|
|
|
|
+ pos.getX() + controller.getScaleDiv2(),
|
|
|
|
+ pos.getY() - controller.getScale(),
|
|
controller.getScaleDiv2(), controller.getScaleDiv2(), null);
|
|
controller.getScaleDiv2(), controller.getScaleDiv2(), null);
|
|
}
|
|
}
|
|
//<-- OldCode
|
|
//<-- OldCode
|
|
@@ -634,8 +623,8 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
|
|
|
|
if (e.getX() > upperNode.getLeftBorder()) {
|
|
if (e.getX() > upperNode.getLeftBorder()) {
|
|
for (AbstractCanvasObject cps : upperNode.getNodes()) {
|
|
for (AbstractCanvasObject cps : upperNode.getNodes()) {
|
|
- cx = cps.getPosition().x - model.getScaleDiv2();
|
|
|
|
- cy = cps.getPosition().y - model.getScaleDiv2();
|
|
|
|
|
|
+ cx = cps.getPosition().getX() - model.getScaleDiv2();
|
|
|
|
+ cy = cps.getPosition().getY() - model.getScaleDiv2();
|
|
if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
|
|
if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
|
|
tempCps = cps;
|
|
tempCps = cps;
|
|
|
|
|
|
@@ -751,7 +740,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
/**
|
|
/**
|
|
* check if tempCps could replace an Object on the UpperNodeanvas
|
|
* check if tempCps could replace an Object on the UpperNodeanvas
|
|
*/
|
|
*/
|
|
- if(model.getSelectedCpsObjects().size() == 1 && checkForReplacement(upperNode.getNodes(), tempCps, tempCps.getPosition().x, tempCps.getPosition().y)){
|
|
|
|
|
|
+ if(model.getSelectedCpsObjects().size() == 1 && checkForReplacement(upperNode.getNodes(), tempCps, tempCps.getPosition().getX(), tempCps.getPosition().getY())){
|
|
/**
|
|
/**
|
|
* if UpperNode would be replaced, close its tabs
|
|
* if UpperNode would be replaced, close its tabs
|
|
*/
|
|
*/
|
|
@@ -823,22 +812,22 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
y = this.getHeight() - controller.getScaleDiv2();
|
|
y = this.getHeight() - controller.getScaleDiv2();
|
|
|
|
|
|
// Distance
|
|
// Distance
|
|
- xDist = x - tempCps.getPosition().x;
|
|
|
|
- yDist = y - tempCps.getPosition().y;
|
|
|
|
|
|
+ xDist = x - tempCps.getPosition().getX();
|
|
|
|
+ yDist = y - tempCps.getPosition().getY();
|
|
|
|
|
|
tempCps.setPosition(x, y); // Drag Position
|
|
tempCps.setPosition(x, y); // Drag Position
|
|
|
|
|
|
// TipText Position and name
|
|
// TipText Position and name
|
|
toolTip = true;
|
|
toolTip = true;
|
|
toolTipText = tempCps.getName() + ", " + tempCps.getId();
|
|
toolTipText = tempCps.getName() + ", " + tempCps.getId();
|
|
- toolTipPos.x = tempCps.getPosition().x - model.getScaleDiv2();
|
|
|
|
- toolTipPos.y = tempCps.getPosition().y + model.getScaleDiv2();
|
|
|
|
|
|
+ toolTipPos.setX(tempCps.getPosition().getX() - model.getScaleDiv2());
|
|
|
|
+ toolTipPos.setY(tempCps.getPosition().getY() - model.getScaleDiv2());
|
|
|
|
|
|
// All Selected Objects
|
|
// All Selected Objects
|
|
for (AbstractCanvasObject cps : model.getSelectedCpsObjects()) {
|
|
for (AbstractCanvasObject cps : model.getSelectedCpsObjects()) {
|
|
if (cps != tempCps) {
|
|
if (cps != tempCps) {
|
|
- x = (int) (cps.getPosition().x + xDist);
|
|
|
|
- y = (int) (cps.getPosition().y + yDist);
|
|
|
|
|
|
+ x = (int) (cps.getPosition().getX() + xDist);
|
|
|
|
+ y = (int) (cps.getPosition().getY() + yDist);
|
|
|
|
|
|
// Make sure its in bounds
|
|
// Make sure its in bounds
|
|
if (x < upperNode.getLeftBorder() + 5 + controller.getScaleDiv2())
|
|
if (x < upperNode.getLeftBorder() + 5 + controller.getScaleDiv2())
|
|
@@ -881,8 +870,8 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
y1 = y;
|
|
y1 = y;
|
|
y2 = sy;
|
|
y2 = sy;
|
|
}
|
|
}
|
|
- if (x1 <= cps.getPosition().x + model.getScaleDiv2() && y1 <= cps.getPosition().y + model.getScaleDiv2()
|
|
|
|
- && x2 >= cps.getPosition().x && y2 >= cps.getPosition().y) {
|
|
|
|
|
|
+ if (x1 <= cps.getPosition().getX() + model.getScaleDiv2() && y1 <= cps.getPosition().getY() + model.getScaleDiv2()
|
|
|
|
+ && x2 >= cps.getPosition().getX() && y2 >= cps.getPosition().getY()) {
|
|
tempSelected.add(cps);
|
|
tempSelected.add(cps);
|
|
|
|
|
|
}
|
|
}
|
|
@@ -931,8 +920,8 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
boolean on = false;
|
|
boolean on = false;
|
|
for (AbstractCanvasObject cps : upperNode.getNodes()) {
|
|
for (AbstractCanvasObject cps : upperNode.getNodes()) {
|
|
|
|
|
|
- cx = cps.getPosition().x - controller.getScaleDiv2();
|
|
|
|
- cy = cps.getPosition().y - controller.getScaleDiv2();
|
|
|
|
|
|
+ cx = cps.getPosition().getX() - controller.getScaleDiv2();
|
|
|
|
+ cy = cps.getPosition().getY() - controller.getScaleDiv2();
|
|
|
|
|
|
on = setToolTipInfoAndPosition(on, cps);
|
|
on = setToolTipInfoAndPosition(on, cps);
|
|
}
|
|
}
|
|
@@ -951,8 +940,8 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
if (x - 50 <= cx && y - 50 <= cy && x >= cx && y >= cy) {
|
|
if (x - 50 <= cx && y - 50 <= cy && x >= cx && y >= cy) {
|
|
|
|
|
|
on = true;
|
|
on = true;
|
|
- toolTipPos.x = cx - 25;
|
|
|
|
- toolTipPos.y = cy + 50;
|
|
|
|
|
|
+ toolTipPos.setX(cx - 25);
|
|
|
|
+ toolTipPos.setY(cy + 50);
|
|
toolTipText = cps.getName() + ", " + cps.getId();
|
|
toolTipText = cps.getName() + ", " + cps.getId();
|
|
|
|
|
|
}
|
|
}
|
|
@@ -978,8 +967,8 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
Edge e = null;
|
|
Edge e = null;
|
|
for (AbstractCanvasObject cps : upperNode.getNodes()) {
|
|
for (AbstractCanvasObject cps : upperNode.getNodes()) {
|
|
|
|
|
|
- cx = cps.getPosition().x - controller.getScaleDiv2();
|
|
|
|
- cy = cps.getPosition().y - controller.getScaleDiv2();
|
|
|
|
|
|
+ cx = cps.getPosition().getX() - controller.getScaleDiv2();
|
|
|
|
+ cy = cps.getPosition().getY() - controller.getScaleDiv2();
|
|
|
|
|
|
if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy
|
|
if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy
|
|
&& cps != tempCps) {
|
|
&& cps != tempCps) {
|
|
@@ -1142,8 +1131,8 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
|
|
|
|
//TODO: is this right
|
|
//TODO: is this right
|
|
// for (CpsEdge p : upperNode.getNodeEdges()) {
|
|
// for (CpsEdge p : upperNode.getNodeEdges()) {
|
|
-// Line2D l = new Line2D.Float(p.getA().getPosition().x, p.getA().getPosition().y, p.getB().getPosition().x,
|
|
|
|
-// p.getB().getPosition().y);
|
|
|
|
|
|
+// Line2D l = new Line2D.Float(p.getA().getPosition().getX(), p.getA().getPosition().getY(), p.getB().getPosition().getX(),
|
|
|
|
+// p.getB().getPosition().getY());
|
|
//
|
|
//
|
|
// int[] positions = determineMousePositionOnEdge(p);
|
|
// int[] positions = determineMousePositionOnEdge(p);
|
|
// lx = positions[0];
|
|
// lx = positions[0];
|
|
@@ -1182,21 +1171,21 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
// 5 + (50 + scalediv20 + 10) * count), 50, 50, null);
|
|
// 5 + (50 + scalediv20 + 10) * count), 50, 50, null);
|
|
if (doTest) {
|
|
if (doTest) {
|
|
Line2D l = new Line2D.Float((upperNode.getLeftBorder() >> 1) - 25,
|
|
Line2D l = new Line2D.Float((upperNode.getLeftBorder() >> 1) - 25,
|
|
- (int) (scalediv20 + 5 + 25 + (50 + scalediv20 + 10) * count), obj.getPosition().x,
|
|
|
|
- obj.getPosition().y);
|
|
|
|
- if ((upperNode.getLeftBorder() >> 1) > obj.getPosition().x) {
|
|
|
|
|
|
+ (int) (scalediv20 + 5 + 25 + (50 + scalediv20 + 10) * count), obj.getPosition().getX(),
|
|
|
|
+ obj.getPosition().getY());
|
|
|
|
+ if ((upperNode.getLeftBorder() >> 1) > obj.getPosition().getX()) {
|
|
hx = (upperNode.getLeftBorder() >> 1) - 25 + model.getScaleDiv2() + 7;
|
|
hx = (upperNode.getLeftBorder() >> 1) - 25 + model.getScaleDiv2() + 7;
|
|
- lx = obj.getPosition().x + model.getScaleDiv2() - 7;
|
|
|
|
|
|
+ lx = obj.getPosition().getX() + model.getScaleDiv2() - 7;
|
|
} else {
|
|
} else {
|
|
lx = (upperNode.getLeftBorder() >> 1) - 25 + model.getScaleDiv2() - 7;
|
|
lx = (upperNode.getLeftBorder() >> 1) - 25 + model.getScaleDiv2() - 7;
|
|
- hx = obj.getPosition().x + model.getScaleDiv2() + 7;
|
|
|
|
|
|
+ hx = obj.getPosition().getX() + model.getScaleDiv2() + 7;
|
|
}
|
|
}
|
|
- if ((int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count) > obj.getPosition().y) {
|
|
|
|
|
|
+ if ((int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count) > obj.getPosition().getY()) {
|
|
hy = (int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count) + model.getScaleDiv2() + 7;
|
|
hy = (int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count) + model.getScaleDiv2() + 7;
|
|
- ly = obj.getPosition().y + model.getScaleDiv2() - 7;
|
|
|
|
|
|
+ ly = obj.getPosition().getY() + model.getScaleDiv2() - 7;
|
|
} else {
|
|
} else {
|
|
ly = (int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count) + model.getScaleDiv2() - 7;
|
|
ly = (int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count) + model.getScaleDiv2() - 7;
|
|
- hy = obj.getPosition().y + model.getScaleDiv2() + 7;
|
|
|
|
|
|
+ hy = obj.getPosition().getY() + model.getScaleDiv2() + 7;
|
|
}
|
|
}
|
|
|
|
|
|
// distance from a point to a line and between both Objects
|
|
// distance from a point to a line and between both Objects
|