|
@@ -484,54 +484,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
|
|
cps.getPosition().y - controller.getScaleDiv2(),
|
|
cps.getPosition().y - controller.getScaleDiv2(),
|
|
controller.getScale(), controller.getScale(), null);
|
|
controller.getScale(), controller.getScale(), null);
|
|
|
|
|
|
- /**
|
|
|
|
- * draw and fill the supply Bar
|
|
|
|
- */
|
|
|
|
- if (model.getShowSupplyBars() && cps instanceof HolonObject) {
|
|
|
|
- HolonObject hl = (HolonObject) cps;
|
|
|
|
- if (hl != null
|
|
|
|
- && (hl.getState() == HolonObject.NOT_SUPPLIED || hl
|
|
|
|
- .getState() == HolonObject.PARTIALLY_SUPPLIED)) {
|
|
|
|
- // calculate Positons:
|
|
|
|
- int barX = (int) (cps.getPosition().x
|
|
|
|
- - controller.getScaleDiv2() - scalediv20);
|
|
|
|
- int barY = (int) (cps.getPosition().y
|
|
|
|
- - controller.getScaleDiv2() + controller.getScale() + 1);
|
|
|
|
- int barWidth = (int) (controller.getScale()
|
|
|
|
- + ((scalediv20) * 2) - 1);
|
|
|
|
- int barHeight = (int) (controller.getScale() / 5);
|
|
|
|
-
|
|
|
|
- // draw Rectangle under the image
|
|
|
|
- g2.setStroke(new BasicStroke(1));
|
|
|
|
- g2.drawRect(barX, barY, barWidth, barHeight);
|
|
|
|
-
|
|
|
|
- // get supplied status
|
|
|
|
- float percentage = hl.getSuppliedPercentage();
|
|
|
|
-
|
|
|
|
- // set Color
|
|
|
|
- g2.setColor(hl.getColor());
|
|
|
|
-
|
|
|
|
- // fill it accordingly
|
|
|
|
- g2.fillRect(barX + 1, barY + 1,
|
|
|
|
- (int) ((barWidth - 1) * percentage), barHeight - 1);
|
|
|
|
-
|
|
|
|
- // write percentage
|
|
|
|
- g2.setColor(Color.BLACK);
|
|
|
|
- Font oldFont = g2.getFont();
|
|
|
|
- g.setFont(new Font("TimesRoman", Font.PLAIN,
|
|
|
|
- (int) (barHeight * 1.5) - 2));
|
|
|
|
-
|
|
|
|
- String percentageString = (Math.round((percentage * 100)))
|
|
|
|
- + "%";
|
|
|
|
-
|
|
|
|
- int stringWidth = (int) g2.getFontMetrics()
|
|
|
|
- .getStringBounds(percentageString, g2).getWidth();
|
|
|
|
- g2.drawString(percentageString, barX + barWidth / 2 + 1
|
|
|
|
- - stringWidth / 2, barY + barHeight);
|
|
|
|
-
|
|
|
|
- g2.setFont(oldFont);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ paintSupplyBar(g, cps);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -545,6 +498,8 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
|
|
showTooltip(g);
|
|
showTooltip(g);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void mouseClicked(MouseEvent e) {
|
|
public void mouseClicked(MouseEvent e) {
|
|
if (e.getButton() == MouseEvent.BUTTON1) {
|
|
if (e.getButton() == MouseEvent.BUTTON1) {
|