summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java
diff options
context:
space:
mode:
authorSimon Rettberg2015-08-22 23:34:02 +0200
committerSimon Rettberg2015-08-22 23:34:02 +0200
commitc562efd9aa4c27b4c2546427829c2ed46169531a (patch)
treeb8788ea0ee364f61cf68fad85837471a2b3d2c33 /dozentenmodul/src/main/java
parent[server] Work on version deletion/change/validity logic (diff)
downloadtutor-module-c562efd9aa4c27b4c2546427829c2ed46169531a.tar.gz
tutor-module-c562efd9aa4c27b4c2546427829c2ed46169531a.tar.xz
tutor-module-c562efd9aa4c27b4c2546427829c2ed46169531a.zip
[client] Fix PersonLabel link color calculation, minor optimizations to BlockProgressBar
Diffstat (limited to 'dozentenmodul/src/main/java')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/BlockProgressBar.java31
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/PersonLabel.java10
2 files changed, 22 insertions, 19 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/BlockProgressBar.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/BlockProgressBar.java
index 8a25f409..04f6c14a 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/BlockProgressBar.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/BlockProgressBar.java
@@ -3,7 +3,6 @@ package org.openslx.dozmod.gui.control;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
-import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@@ -75,26 +74,30 @@ public class BlockProgressBar extends JPanel {
((Graphics2D) g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
}
- final float width = getWidth();
+ final int width = getWidth();
final int height = getHeight();
final float complete = blocks.getComplete();
- final float doneWidth = width * complete;
- final Rectangle doneRect = new Rectangle(0, 0, (int) doneWidth, height);
- final Rectangle remainingRect = new Rectangle((int) doneWidth, 0, (int) (width - doneWidth), height);
+ final int doneWidth = (int)((float)width * complete);
g.setColor(Color.BLUE);
- g.fillRect(doneRect.x, doneRect.y, doneRect.width, doneRect.height);
+ g.fillRect(0, 0, doneWidth, height);
g.setColor(Color.WHITE);
- g.fillRect(remainingRect.x, remainingRect.y, remainingRect.width, remainingRect.height);
+ g.fillRect(doneWidth, 0, width - doneWidth, height);
final String progress = (int) (complete * 100) + "%";
Rectangle2D textExtent = g.getFontMetrics().getStringBounds(progress, g);
- final int textX = (int) ((width - textExtent.getWidth()) / 2);
+ final double tw = textExtent.getWidth();
+ final int textX = (int) ((width - tw) / 2);
+ final int textXEnd = (int) ((width + tw) / 2);
final int textY = (int) ((height + textExtent.getHeight()) / 2);
- g.setColor(Color.WHITE);
- g.setClip(doneRect.x, doneRect.y, doneRect.width, doneRect.height);
- g.drawString(progress, textX, textY);
- g.setColor(Color.BLACK);
- g.setClip(remainingRect.x, remainingRect.y, remainingRect.width, remainingRect.height);
- g.drawString(progress, textX, textY);
+ if (doneWidth >= textX) {
+ g.setColor(Color.WHITE);
+ g.setClip(0, 0, doneWidth, height);
+ g.drawString(progress, textX, textY);
+ }
+ if (doneWidth <= textXEnd) {
+ g.setColor(Color.BLACK);
+ g.setClip(doneWidth, 0, width - doneWidth, height);
+ g.drawString(progress, textX, textY);
+ }
}
private void drawDetailed(Graphics g) {
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/PersonLabel.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/PersonLabel.java
index 4ddec86c..8299cb35 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/PersonLabel.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/PersonLabel.java
@@ -50,11 +50,11 @@ public class PersonLabel extends JLabel {
int g = tc.getGreen() * tc.getGreen();
int b = tc.getBlue() * tc.getBlue();
b += 30000;
- double factor = 65535 / b;
+ double factor = 65025 / b;
if (factor < 1) {
- r *= factor;
- g *= factor;
- b *= factor;
+ r = (int)((double)r * factor);
+ g = (int)((double)g * factor);
+ b = (int)((double)b * factor);
}
r = (int) Math.sqrt(r);
g = (int) Math.sqrt(g);
@@ -89,7 +89,7 @@ public class PersonLabel extends JLabel {
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
setForeground(UIManager.getColor("Label.foreground"));
} else {
- setToolTipText("Klicken, um eine Mail an diesen Benutzer zu senden");
+ setToolTipText("Klicken, um eine Mail an diese Person zu senden");
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
setForeground(linkColor());
}