Manage {config} token in -setp option

This commit is contained in:
2018-08-23 09:53:19 +02:00
parent 52a8daf5c0
commit 810740ddca
12 changed files with 624 additions and 534 deletions

View File

@@ -3,18 +3,9 @@
*/
package ch.psi.mxsc;
import ch.psi.mxsc.BasePlate.SelectionMode;
import ch.psi.pshell.device.Device;
import ch.psi.pshell.device.DeviceBase;
import ch.psi.pshell.imaging.DimensionDouble;
import ch.psi.pshell.imaging.PointDouble;
import ch.psi.utils.swing.SwingUtils;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
/**
*
@@ -56,7 +47,7 @@ public class Sample extends DeviceBase {
boolean selected;
public boolean isSelected() {
return selected && (getPuck().getBasePlate().getSelectionMode() == SelectionMode.Samples);
return selected;
}
public void toggleSelected(boolean value) {
@@ -107,87 +98,4 @@ public class Sample extends DeviceBase {
return wasLoaded;
}
Color getColor() {
Color ret = Color.LIGHT_GRAY;
if (isLoaded()) {
ret = Color.BLUE;
} else if (wasLoaded()) {
ret = Color.GREEN;
} else if (isPresent()) {
ret = Color.CYAN.darker().darker();
}
if (isSelected()) {
ret = ret.brighter();
}
return ret;
}
int getNormalDrawSize() {
return getPuck().getDrawSize(getSize().getWidth() );
}
int getDrawSize() {
int ret = getNormalDrawSize();
if (isSelected()) {
ret += 2;
}
return ret;
}
Point getDrawPosition() {
return getPuck().getDrawPosition(getPuck().getSamplePosition(this));
}
Color getLabelColor(boolean drawBackground) {
return drawBackground ? getPuck().isHighlithted() ? Color.DARK_GRAY : new Color(92, 92, 92) : new Color (0,96,0);
}
Font getLabelFont() {
////return new Font("Times New Roman", Font.PLAIN, 8);
//return new Font("Courier New", Font.PLAIN, 8);
return new Font("Tahoma", Font.PLAIN, 8);
}
Point getLabelPosition(String text, Graphics g) {
Point center = getDrawPosition();
Dimension textSize = SwingUtils.getTextSize(text, g.getFontMetrics());
return new Point(center.x - textSize.width / 2 + 1, center.y + (g.getFontMetrics().getAscent()/2));
}
Color getBorderColor(boolean drawBackground) {
if (drawBackground){
if (!isEnabled()) {
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){
Point position = getDrawPosition();
int size = getDrawSize();
if (drawBackground){
g.setColor(getColor());
g.fillOval(position.x - size / 2, position.y - size / 2, size, size);
}
g.setColor(getBorderColor(drawBackground));
g.drawOval(position.x - size / 2, position.y - size / 2, size, size);
if (getNormalDrawSize()>10){
String text = String.valueOf(index + 1);
g.setColor(getLabelColor(drawBackground));
g.setFont(getLabelFont());
Point labelPosition = getLabelPosition(text, g);
g.drawString(text, labelPosition.x, labelPosition.y);
}
g.setPaintMode();
}
}