소스 검색

moves SupplyBars below the ReplacementHighlight

Andreas T. Meyer-Berg 6 년 전
부모
커밋
f2fecedca1
1개의 변경된 파일26개의 추가작업 그리고 29개의 파일을 삭제
  1. 26 29
      src/ui/view/AbstractCanvas.java

+ 26 - 29
src/ui/view/AbstractCanvas.java

@@ -189,8 +189,7 @@ public abstract class AbstractCanvas extends JPanel {
 			{
 				HolonObject hl = (HolonObject) cps;
 				if (hl == null || !(hl.getState() == HolonObject.NOT_SUPPLIED
-						|| hl.getState() == HolonObject.PARTIALLY_SUPPLIED || hl.getState() == HolonObject.OVER_SUPPLIED
-				/* || hl.getState() == HolonObject.SUPPLIED */)) 
+						|| hl.getState() == HolonObject.PARTIALLY_SUPPLIED || hl.getState() == HolonObject.OVER_SUPPLIED)) 
 				{
 					return;
 				}
@@ -242,6 +241,10 @@ public abstract class AbstractCanvas extends JPanel {
 			// calculate Positons:
 			int barX = (int) (cps.getPosition().x - controller.getScaleDiv2() - scalediv20);
 			int barY = (int) (cps.getPosition().y - controller.getScaleDiv2() + controller.getScale() + 1);
+			/**
+			 * if object should be replaced -> move bar below the ReplacementIndicator
+			 */
+			if(mayBeReplaced==cps) barY += 6;
 			int barWidth = (int) (controller.getScale() + ((scalediv20) * 2) - 1);
 			int barHeight = (int) (controller.getScale() / 5);
 
@@ -249,35 +252,29 @@ public abstract class AbstractCanvas extends JPanel {
 			g2.setStroke(new BasicStroke(1));
 			g2.drawRect(barX, barY, barWidth, barHeight);
 				
-				
-	
 			g2.setColor(paintColor);
-				
-	
-				
-	
-				// fill it accordingly if filled partially
-				if (percentage < 1)
-					g2.fillRect(barX + 1, barY + 1, (int) ((barWidth - 1) * percentage), barHeight - 1);
-				else //over supplied / supplied bar
-					g2.fillRect(barX + 1, barY + 1, (int) (barWidth - 1), barHeight - 1);
-				
-				// write percentage
-				if(percentage>1)
-					g2.setColor(Color.WHITE);
-				else
-					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);
+
+			// fill it accordingly if filled partially
+			if (percentage < 1)
+				g2.fillRect(barX + 1, barY + 1, (int) ((barWidth - 1) * percentage), barHeight - 1);
+			else //over supplied / supplied bar
+				g2.fillRect(barX + 1, barY + 1, (int) (barWidth - 1), barHeight - 1);
+			
+			// write percentage
+			if(percentage>1)
+				g2.setColor(Color.WHITE);
+			else
 				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);
+			g2.setColor(Color.BLACK);
 				
 		}
 	}