MainPanel prototype

This commit is contained in:
gac-S_Changer
2018-04-10 09:50:23 +02:00
parent fd15d2cf48
commit 1e2fee44d0
7 changed files with 75 additions and 37 deletions

View File

@@ -140,8 +140,8 @@ public class Sample extends DeviceBase {
}
Color getLabelColor() {
return Color.DARK_GRAY;
Color getLabelColor(boolean drawBackground) {
return drawBackground ? Color.DARK_GRAY : new Color (0,128,0);
}
Font getLabelFont() {
@@ -155,13 +155,16 @@ public class Sample extends DeviceBase {
return new Point(center.x - textSize.width / 2 + 1, center.y + (g.getFontMetrics().getAscent()/2));
}
Color getBorderColor() {
if (!isEnabled()) {
Color getBorderColor(boolean drawBackground) {
if (drawBackground){
if (!isEnabled()) {
return Color.GRAY;
} else if (isSelected()) {
return new Color(32,32,32);
}
return Color.GRAY;
} else if (isSelected()) {
return new Color(32,32,32);
}
return Color.GRAY;
return isSelected() ? new Color(0,32,0) : new Color(0,128,0);
}
void draw (Graphics2D g, boolean drawBackground){
@@ -172,13 +175,13 @@ public class Sample extends DeviceBase {
g.setColor(getColor());
g.fillOval(position.x - size / 2, position.y - size / 2, size, size);
}
g.setColor(getBorderColor());
g.setColor(getBorderColor(drawBackground));
g.drawOval(position.x - size / 2, position.y - size / 2, size, size);
String text = String.valueOf(index + 1);
Point labelPosition = getLabelPosition(text, g);
if (getNormalDrawSize()>10){
g.setColor(getLabelColor());
g.setColor(getLabelColor(drawBackground));
g.setFont(getLabelFont());
g.drawString(text, labelPosition.x, labelPosition.y);
}