|
@@ -43,6 +43,9 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
private double width = -1;
|
|
private double width = -1;
|
|
private double height = -1;
|
|
private double height = -1;
|
|
|
|
|
|
|
|
+ private boolean isElement = true;
|
|
|
|
+ private boolean isSwitch = true;
|
|
|
|
+
|
|
private HolonElement tempElement;
|
|
private HolonElement tempElement;
|
|
private Model model;
|
|
private Model model;
|
|
private Control controller;
|
|
private Control controller;
|
|
@@ -82,61 +85,79 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
|
|
|
|
graphCurve.reset();
|
|
graphCurve.reset();
|
|
|
|
|
|
- // Draw the Vertical Lines
|
|
|
|
- g2.setColor(Color.BLACK);
|
|
|
|
- for (int i = 0; i <= this.getWidth(); i += 10) {
|
|
|
|
- g2.drawLine(i, 0, i, this.getHeight());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for (int i = 0; i <= this.getHeight(); i += 5) {
|
|
|
|
- g2.drawLine(0, i, this.getWidth(), i);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (arrayOfValue != null) {
|
|
|
|
- // array fillen
|
|
|
|
- fillArrayofValue();
|
|
|
|
|
|
+ if (isElement) {
|
|
|
|
|
|
- // Draw the Lines
|
|
|
|
- g2.setStroke(new BasicStroke(2));
|
|
|
|
|
|
+ // Draw the Vertical Lines
|
|
g2.setColor(Color.BLACK);
|
|
g2.setColor(Color.BLACK);
|
|
- for (int i = 0; i < pointList.size() - 1; i++) {
|
|
|
|
- c = buildCurve(pointList.get(i), pointList.get(i + 1));
|
|
|
|
- graphCurve.append(c, true);
|
|
|
|
|
|
+ for (int i = 0; i <= this.getWidth(); i += 10) {
|
|
|
|
+ g2.drawLine(i, 0, i, this.getHeight());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i <= this.getHeight(); i += 5) {
|
|
|
|
+ g2.drawLine(0, i, this.getWidth(), i);
|
|
}
|
|
}
|
|
- g2.draw(graphCurve);
|
|
|
|
|
|
|
|
- // Draw the Points
|
|
|
|
|
|
+ if (arrayOfValue != null) {
|
|
|
|
+ // array fillen
|
|
|
|
+ fillArrayofValue();
|
|
|
|
+
|
|
|
|
+ // Draw the Lines
|
|
|
|
+ g2.setStroke(new BasicStroke(2));
|
|
|
|
+ g2.setColor(Color.BLACK);
|
|
|
|
+ for (int i = 0; i < pointList.size() - 1; i++) {
|
|
|
|
+ c = buildCurve(pointList.get(i), pointList.get(i + 1));
|
|
|
|
+ graphCurve.append(c, true);
|
|
|
|
+ }
|
|
|
|
+ g2.draw(graphCurve);
|
|
|
|
+
|
|
|
|
+ // Draw the Points
|
|
|
|
+ g2.setColor(Color.BLUE);
|
|
|
|
+ for (int i = 0; i < pointList.size() - 0; i++) {
|
|
|
|
+ g2.fillOval((int) (pointList.get(i).getX() * scaleX - recSize.getX() / 2),
|
|
|
|
+ (int) (pointList.get(i).getY() * scaleY - recSize.getY() / 2), (int) recSize.getX(),
|
|
|
|
+ (int) recSize.getY());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Iteration Line
|
|
g2.setColor(Color.BLUE);
|
|
g2.setColor(Color.BLUE);
|
|
- for (int i = 0; i < pointList.size() - 0; i++) {
|
|
|
|
- g2.fillOval((int) (pointList.get(i).getX() * scaleX - recSize.getX() / 2),
|
|
|
|
- (int) (pointList.get(i).getY() * scaleY - recSize.getY() / 2), (int) recSize.getX(),
|
|
|
|
- (int) recSize.getY());
|
|
|
|
|
|
+ g2.setStroke(new BasicStroke(1));
|
|
|
|
+ g2.drawLine((model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1), 0,
|
|
|
|
+ (model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1), this.getHeight());
|
|
|
|
+ // Iteration Value
|
|
|
|
+ if (arrayOfValue != null) {
|
|
|
|
+ g2.drawString("" + arrayOfValue[model.getCurIteration()],
|
|
|
|
+ (model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1) + 2,
|
|
|
|
+ this.getHeight() - 10);
|
|
}
|
|
}
|
|
- }
|
|
|
|
- // Iteration Line
|
|
|
|
- g2.setColor(Color.BLUE);
|
|
|
|
- g2.setStroke(new BasicStroke(1));
|
|
|
|
- g2.drawLine((model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1), 0,
|
|
|
|
- (model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1), this.getHeight());
|
|
|
|
- // Iteration Value
|
|
|
|
- if (arrayOfValue != null) {
|
|
|
|
- g2.drawString("" + arrayOfValue[model.getCurIteration()],
|
|
|
|
- (model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1) + 2,
|
|
|
|
- this.getHeight() - 10);
|
|
|
|
- }
|
|
|
|
- /*
|
|
|
|
- * // Actual Iteration Point Visualization g2.setColor(Color.RED); if
|
|
|
|
- * (arrayOfValue != null) { for (int i = 0; i < arrayOfValue.length;
|
|
|
|
- * i++) { g2.fillOval((int) (i * width / (model.getIterations() - 1) *
|
|
|
|
- * scaleX - recSize.getX() / 2), (int) (convertToCanvasY((int)
|
|
|
|
- * arrayOfValue[i]) * scaleY - recSize.getY() / 2), (int)
|
|
|
|
- * recSize.getX(), (int) recSize.getY()); } }
|
|
|
|
- */
|
|
|
|
|
|
+ /*
|
|
|
|
+ * // Actual Iteration Point Visualization g2.setColor(Color.RED);
|
|
|
|
+ * if (arrayOfValue != null) { for (int i = 0; i <
|
|
|
|
+ * arrayOfValue.length; i++) { g2.fillOval((int) (i * width /
|
|
|
|
+ * (model.getIterations() - 1) * scaleX - recSize.getX() / 2), (int)
|
|
|
|
+ * (convertToCanvasY((int) arrayOfValue[i]) * scaleY -
|
|
|
|
+ * recSize.getY() / 2), (int) recSize.getX(), (int) recSize.getY());
|
|
|
|
+ * } }
|
|
|
|
+ */
|
|
|
|
+ } else if (isSwitch) {
|
|
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void mouseDragged(MouseEvent e) {
|
|
public void mouseDragged(MouseEvent e) {
|
|
|
|
+ if (isElement) {
|
|
|
|
+ elementDragged(e);
|
|
|
|
+ } else if (isSwitch) {
|
|
|
|
+ switchDragged(e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Wenn ein Punkt bei einem HolonElement gedragged wird
|
|
|
|
+ *
|
|
|
|
+ * @param e
|
|
|
|
+ */
|
|
|
|
+ public void elementDragged(MouseEvent e) {
|
|
if (pointDrag && tempP != null) {
|
|
if (pointDrag && tempP != null) {
|
|
// Out of Bounds verhindern
|
|
// Out of Bounds verhindern
|
|
int i = pointList.indexOf(tempP);
|
|
int i = pointList.indexOf(tempP);
|
|
@@ -156,31 +177,49 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
tempP.setLocation(x, y);
|
|
tempP.setLocation(x, y);
|
|
repaint();
|
|
repaint();
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Wenn ein Punkt bei einem CpsSwitch gedragged wird
|
|
|
|
+ *
|
|
|
|
+ * @param e
|
|
|
|
+ */
|
|
|
|
+ public void switchDragged(MouseEvent e) {
|
|
|
|
+ // TODO Switch dragged zeugs kommt hier hin
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void mouseMoved(MouseEvent e) {
|
|
public void mouseMoved(MouseEvent e) {
|
|
- // TODO Auto-generated method stub
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void mouseClicked(MouseEvent e) {
|
|
public void mouseClicked(MouseEvent e) {
|
|
- // TODO Auto-generated method stub
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void mouseEntered(MouseEvent e) {
|
|
public void mouseEntered(MouseEvent e) {
|
|
- // TODO Auto-generated method stub
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void mouseExited(MouseEvent e) {
|
|
public void mouseExited(MouseEvent e) {
|
|
- // TODO Auto-generated method stub
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void mousePressed(MouseEvent e) {
|
|
public void mousePressed(MouseEvent e) {
|
|
|
|
+ if (isElement) {
|
|
|
|
+ elementPressed(e);
|
|
|
|
+ } else if (isSwitch) {
|
|
|
|
+ switchPressed(e);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Wenn ein Punkt von einem Element gedrück wird
|
|
|
|
+ *
|
|
|
|
+ * @param e
|
|
|
|
+ */
|
|
|
|
+ public void elementPressed(MouseEvent e) {
|
|
boolean added = false;
|
|
boolean added = false;
|
|
boolean deletePoint = false;
|
|
boolean deletePoint = false;
|
|
|
|
|
|
@@ -228,6 +267,15 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Wenn ein Punkt von einem Switch gedrück wird
|
|
|
|
+ *
|
|
|
|
+ * @param e
|
|
|
|
+ */
|
|
|
|
+ public void switchPressed(MouseEvent e) {
|
|
|
|
+ //TODO Siwtch pressed zeugs hier hin
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void mouseReleased(MouseEvent e) {
|
|
public void mouseReleased(MouseEvent e) {
|
|
if (pointDrag) {
|
|
if (pointDrag) {
|