|
@@ -5,6 +5,7 @@ import classes.*;
|
|
import com.google.gson.JsonParseException;
|
|
import com.google.gson.JsonParseException;
|
|
|
|
|
|
import holeg.HolegPowerFlowContext;
|
|
import holeg.HolegPowerFlowContext;
|
|
|
|
+import javafx.geometry.Pos;
|
|
import ui.controller.Control;
|
|
import ui.controller.Control;
|
|
import ui.controller.SingletonControl;
|
|
import ui.controller.SingletonControl;
|
|
import ui.controller.UpdateController;
|
|
import ui.controller.UpdateController;
|
|
@@ -334,13 +335,6 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
|
|
this.addMouseListener(this);
|
|
this.addMouseListener(this);
|
|
this.addMouseMotionListener(this);
|
|
this.addMouseMotionListener(this);
|
|
}
|
|
}
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Paints all Components on the Canvas.
|
|
|
|
- *
|
|
|
|
- * @param g
|
|
|
|
- * Graphics
|
|
|
|
- */
|
|
|
|
|
|
|
|
private Color getStateColor(HolonObjectState state) {
|
|
private Color getStateColor(HolonObjectState state) {
|
|
switch(state) {
|
|
switch(state) {
|
|
@@ -398,7 +392,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
|
|
pos.y - controller.getScaleDiv2(),
|
|
pos.y - controller.getScaleDiv2(),
|
|
controller.getScale(), controller.getScale() , null);
|
|
controller.getScale(), controller.getScale() , null);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public static void paintCable(Control controller, Graphics2D g, DecoratedCable cable, boolean isSelected, boolean showConnectionInformation) {
|
|
public static void paintCable(Control controller, Graphics2D g, DecoratedCable cable, boolean isSelected, boolean showConnectionInformation) {
|
|
// Find cable start/end
|
|
// Find cable start/end
|
|
AbstractCanvasObject a = cable.getModel().getA();
|
|
AbstractCanvasObject a = cable.getModel().getA();
|
|
@@ -406,6 +400,10 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
|
|
Position start = a.getPosition();
|
|
Position start = a.getPosition();
|
|
Position end = b.getPosition();
|
|
Position end = b.getPosition();
|
|
|
|
|
|
|
|
+ paintCable(controller, g, a, b, start, end, cable, isSelected, showConnectionInformation);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static void paintCable(Control controller, Graphics2D g, AbstractCanvasObject a, AbstractCanvasObject b, Position start, Position end, DecoratedCable cable, boolean isSelected, boolean showConnectionInformation) {
|
|
// Find cable state
|
|
// Find cable state
|
|
float currentEnergy = Math.abs(cable.getFlowEnergy());
|
|
float currentEnergy = Math.abs(cable.getFlowEnergy());
|
|
float capacity = cable.getModel().getCapacity();
|
|
float capacity = cable.getModel().getCapacity();
|
|
@@ -420,9 +418,8 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
|
|
g.setStroke(new BasicStroke(unlimited ? 2f : (Math.min(currentEnergy / capacity, 1) * 2f) + 1));
|
|
g.setStroke(new BasicStroke(unlimited ? 2f : (Math.min(currentEnergy / capacity, 1) * 2f) + 1));
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- if (isSelected) {
|
|
|
|
|
|
+ if (isSelected)
|
|
g.setColor(Color.lightGray);
|
|
g.setColor(Color.lightGray);
|
|
- }
|
|
|
|
|
|
|
|
// Check if we should draw arrow or line
|
|
// Check if we should draw arrow or line
|
|
if (cable.getFlowEnergy() > 2)
|
|
if (cable.getFlowEnergy() > 2)
|
|
@@ -466,27 +463,19 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
|
|
drawCanvasObject(g, dSwitch.getState() == SwitchState.Open ? HolonSwitch.getSwitchOpenImage(): HolonSwitch.getSwitchClosedImage() , dSwitch.getModel().getPosition());
|
|
drawCanvasObject(g, dSwitch.getState() == SwitchState.Open ? HolonSwitch.getSwitchOpenImage(): HolonSwitch.getSwitchClosedImage() , dSwitch.getModel().getPosition());
|
|
}
|
|
}
|
|
|
|
|
|
- private void paintExitCable(Graphics2D g, ExitCable eCable) {
|
|
|
|
- Position start = eCable.getStart().getPosition();
|
|
|
|
- Position end = eCable.getFinish().getPosition();
|
|
|
|
- float currentEnergy = eCable.getCable().getFlowEnergy();
|
|
|
|
- float capacity = eCable.getCable().getModel().getCapacity();
|
|
|
|
- boolean unlimited = eCable.getCable().getModel().isUnlimitedCapacity();
|
|
|
|
- switch(eCable.getCable().getState()) {
|
|
|
|
- case Burned:
|
|
|
|
- g.setColor(Color.RED);
|
|
|
|
- g.setStroke(new BasicStroke(2));
|
|
|
|
- break;
|
|
|
|
- case Working:
|
|
|
|
- g.setColor(new Color(13, 175, 28));
|
|
|
|
- g.setStroke(new BasicStroke(unlimited?2f:(currentEnergy / capacity * 2f) + 1));
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- g.drawLine(start.x, start.y, end.x, end.y);
|
|
|
|
- Position middle = new Position((start.x + end.x) / 2, (start.y + end.y) / 2);
|
|
|
|
- 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);
|
|
|
|
|
|
+ public static void paintExitCable(Control controller, Graphics2D g, ExitCable eCable, boolean showConnectionInformation) {
|
|
|
|
+ AbstractCanvasObject a = eCable.getStart();
|
|
|
|
+ AbstractCanvasObject b = eCable.getFinish();
|
|
|
|
+ paintExitCable(controller, g, a.getPosition(), b.getPosition(), eCable, showConnectionInformation);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public static void paintExitCable(Control controller, Graphics2D g, Position start, Position end, ExitCable eCable, boolean showConnectionInformation) {
|
|
|
|
+ AbstractCanvasObject a = eCable.getStart();
|
|
|
|
+ AbstractCanvasObject b = eCable.getFinish();
|
|
|
|
+ // End and start are reversed
|
|
|
|
+ paintCable(controller, g, a, b, end, start, eCable.getCable(), false, showConnectionInformation);
|
|
|
|
+ }
|
|
|
|
+
|
|
private void paintGroupNode(Graphics2D g, DecoratedGroupNode dGroupNode) {
|
|
private void paintGroupNode(Graphics2D g, DecoratedGroupNode dGroupNode) {
|
|
Position pos = dGroupNode.getModel().getPosition();
|
|
Position pos = dGroupNode.getModel().getPosition();
|
|
g.setColor(Color.lightGray);
|
|
g.setColor(Color.lightGray);
|
|
@@ -608,7 +597,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
|
|
VisualRepresentationalState visualState = controller.getSimManager().getActualVisualRepresentationalState();
|
|
VisualRepresentationalState visualState = controller.getSimManager().getActualVisualRepresentationalState();
|
|
//VisualState Representation:
|
|
//VisualState Representation:
|
|
for(ExitCable cable : visualState.getExitCableList()) {
|
|
for(ExitCable cable : visualState.getExitCableList()) {
|
|
- paintExitCable(g2d, cable);
|
|
|
|
|
|
+ paintExitCable(controller, g2d, cable, showConnectionInformation);
|
|
}
|
|
}
|
|
for(DecoratedCable cable : visualState.getCableList()) {
|
|
for(DecoratedCable cable : visualState.getCableList()) {
|
|
paintCable(controller, g2d, cable, selectedEdges.contains(cable.getModel()), showConnectionInformation);
|
|
paintCable(controller, g2d, cable, selectedEdges.contains(cable.getModel()), showConnectionInformation);
|