This commit is contained in:
@@ -9,6 +9,7 @@ import ch.psi.pshell.imaging.DimensionDouble;
|
||||
import ch.psi.pshell.imaging.PointDouble;
|
||||
import ch.psi.utils.swing.MainFrame;
|
||||
import ch.psi.utils.swing.SwingUtils;
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
@@ -41,6 +42,28 @@ public class Puck extends DeviceBase {
|
||||
new PointDouble(-28.39445573, 44.18263554)
|
||||
};
|
||||
|
||||
static final Character[] SEGMENTS = new Character[]{ 'A', 'A',
|
||||
'F', 'F','F','F','F',
|
||||
'E', 'E','E','E','E',
|
||||
'D', 'D','D','D','D',
|
||||
'C', 'C','C','C','C',
|
||||
'B', 'B','B','B','B',
|
||||
'A', 'A', 'A'};
|
||||
static final int[] NUMBERS = new int[] { 1, 2,
|
||||
5, 4, 3, 1, 2,
|
||||
5, 4, 3, 1, 2,
|
||||
5, 4, 3, 1, 2,
|
||||
5, 4, 3, 1, 2,
|
||||
5, 4, 3, 1, 2,
|
||||
5, 4, 3};
|
||||
static final int[] ADDRESSES = new int[] { 6, 7,
|
||||
5, 4, 3, 1, 2,
|
||||
20, 19, 18, 16, 17,
|
||||
15, 14, 13, 11, 12,
|
||||
30, 29, 28, 26, 27,
|
||||
25, 24, 23, 21, 22,
|
||||
10, 9, 8};
|
||||
|
||||
final static PointDouble referencePosition = new PointDouble(0.0, -66.9 - 0.2);
|
||||
final static Double referenceSize = 6.2 + 0.2;
|
||||
|
||||
@@ -48,11 +71,19 @@ public class Puck extends DeviceBase {
|
||||
|
||||
|
||||
final int index;
|
||||
|
||||
Character segment;
|
||||
final int address;
|
||||
final int number;
|
||||
|
||||
Puck(BasePlate basePlate, int index) {
|
||||
super(String.valueOf(index+1));
|
||||
//super(String.valueOf(index+1));
|
||||
super(SEGMENTS[index] + "" + NUMBERS[index]);
|
||||
this.setParent(basePlate);
|
||||
this.index = index;
|
||||
this.segment = SEGMENTS[index];
|
||||
this.number = NUMBERS[index];
|
||||
this.address = ADDRESSES[index];
|
||||
for (int i =0; i< numberOfSamples; i++){
|
||||
new Sample(this, i);
|
||||
}
|
||||
@@ -80,8 +111,13 @@ public class Puck extends DeviceBase {
|
||||
return samplesPosition[sample.index];
|
||||
}
|
||||
|
||||
|
||||
public boolean isSegmentSelected(){
|
||||
return ("" + getSegment()).equalsIgnoreCase(Controller.getInstance().getHexaposiPosition());
|
||||
}
|
||||
|
||||
public boolean isHighlithted(){
|
||||
return isSelected() || isSegmentSelected();
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return index;
|
||||
@@ -93,10 +129,22 @@ public class Puck extends DeviceBase {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void seId(String value) {
|
||||
public void setId(String value) {
|
||||
id = value;
|
||||
}
|
||||
|
||||
public char getSegment(){
|
||||
return segment;
|
||||
}
|
||||
|
||||
public int getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public int getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
boolean enabled;
|
||||
|
||||
public boolean isEnabled() {
|
||||
@@ -124,10 +172,10 @@ public class Puck extends DeviceBase {
|
||||
return detectionError;
|
||||
}
|
||||
|
||||
boolean selected;
|
||||
private boolean selected;
|
||||
|
||||
public boolean isSelected() {
|
||||
return selected;
|
||||
return selected && getBasePlate().isSelectable();
|
||||
}
|
||||
|
||||
public void setSelected(boolean value) {
|
||||
@@ -154,22 +202,18 @@ public class Puck extends DeviceBase {
|
||||
Color ret = Color.LIGHT_GRAY;
|
||||
switch (detection){
|
||||
case Empty:
|
||||
ret = Color.LIGHT_GRAY;
|
||||
ret = isHighlithted() ? new Color(224, 224, 224) : Color.LIGHT_GRAY;
|
||||
break;
|
||||
case Present:
|
||||
ret = new Color(0, 92, 92);
|
||||
ret = isHighlithted() ? new Color(0, 140, 140) : new Color(128, 192, 192);
|
||||
break;
|
||||
case Error:
|
||||
ret = new Color(128, 0, 0);
|
||||
ret = isHighlithted() ? new Color(192, 10, 10) : new Color(192, 128, 128);
|
||||
break;
|
||||
case Offline:
|
||||
ret = new Color(92, 92, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
boolean selected = isSelected();
|
||||
if (isSelected()) {
|
||||
ret = ret.brighter();
|
||||
ret = isHighlithted() ? new Color(250, 255, 48) : new Color(253, 194, 41);
|
||||
//ret = isHighlithted() ? new Color(230, 142, 40) : new Color(216, 159, 93);
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -186,7 +230,7 @@ public class Puck extends DeviceBase {
|
||||
(int)((getSize().getWidth() / getBasePlate().getSize().getWidth()) * plotRect.width),
|
||||
(int)((getSize().getHeight() / getBasePlate().getSize().getHeight()) * plotRect.height)
|
||||
);
|
||||
if (isSelected()) {
|
||||
if (isHighlithted()) {
|
||||
ret += 2;
|
||||
}
|
||||
return ret;
|
||||
@@ -207,7 +251,8 @@ public class Puck extends DeviceBase {
|
||||
}
|
||||
|
||||
Color getLabelColor(boolean drawBackground) {
|
||||
return drawBackground ? Color.BLACK : new Color (0,196,0);
|
||||
return drawBackground ? (isHighlithted() ? Color.BLACK : new Color(92, 92, 92)) : (isHighlithted() ? new Color (0,255,0) : new Color (0,162,0));
|
||||
|
||||
}
|
||||
|
||||
Font getLabelFont() {
|
||||
@@ -232,16 +277,21 @@ public class Puck extends DeviceBase {
|
||||
|
||||
Color getBorderColor(boolean drawBackground) {
|
||||
if (drawBackground){
|
||||
if (!isEnabled()){
|
||||
/*if (!isEnabled()){
|
||||
return Color.GRAY;
|
||||
} else if (isSelected()){
|
||||
} else */
|
||||
if (isHighlithted()){
|
||||
return new Color(32,32,32);
|
||||
}
|
||||
return Color.GRAY;
|
||||
}
|
||||
return isSelected() ? new Color(0,32,0) : new Color(0,128,0);
|
||||
return isHighlithted() ? new Color(0,208,0) : new Color(0,128,0);
|
||||
}
|
||||
|
||||
int getBorderWidth(boolean drawBackground) {
|
||||
return drawBackground ? isHighlithted() ? 2 : 1: isHighlithted() ? 2 : 1 ;
|
||||
}
|
||||
|
||||
int getReferenceDrawSize() {
|
||||
return (int)((referenceSize / getSize().getWidth()) * getDrawSize());
|
||||
}
|
||||
@@ -267,8 +317,9 @@ public class Puck extends DeviceBase {
|
||||
g.fillOval(position.x - size / 2, position.y - size / 2, size, size);
|
||||
}
|
||||
g.setColor(getBorderColor(drawBackground));
|
||||
g.setStroke(new BasicStroke(getBorderWidth(drawBackground)));
|
||||
g.drawOval(position.x - size / 2, position.y - size / 2, size, size);
|
||||
|
||||
g.setStroke(new BasicStroke(1f));
|
||||
if (drawSamples){
|
||||
//Draw samples
|
||||
for (Sample sample: getSamples()) {
|
||||
@@ -285,12 +336,16 @@ public class Puck extends DeviceBase {
|
||||
g.setColor(refColor);
|
||||
position = getReferenceDrawPosition();
|
||||
size = getReferenceDrawSize();
|
||||
g.fillArc(position.x - size / 2, position.y - size / 2, size, size, 180, 180);
|
||||
|
||||
if (drawBackground){
|
||||
g.fillArc(position.x - size / 2, position.y - size / 2, size, size, 180, 180);
|
||||
}
|
||||
|
||||
//Draw text
|
||||
String text = String.valueOf(getIndex() + 1);
|
||||
String text = getName(); //String.valueOf(getIndex() + 1);
|
||||
Point labelPosition = getLabelPosition(text, g);
|
||||
g.setColor(getLabelColor(drawBackground));
|
||||
g.setFont(getLabelFont());
|
||||
g.drawString(text, labelPosition.x, labelPosition.y);
|
||||
if (drawId){
|
||||
String id = getId();
|
||||
if (id!=null) {
|
||||
@@ -300,7 +355,5 @@ public class Puck extends DeviceBase {
|
||||
g.drawString(id, getDrawPosition().x - textSize.width/2 , getDrawPosition().y + 10 );
|
||||
}
|
||||
}
|
||||
g.setFont(getLabelFont());
|
||||
g.drawString(text, labelPosition.x, labelPosition.y);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user