Manage {config} token in -setp option
This commit is contained in:
@@ -7,14 +7,6 @@ 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.pshell.imaging.Utils;
|
||||
import ch.psi.utils.swing.MainFrame;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -78,19 +70,7 @@ public class BasePlate extends DeviceBase {
|
||||
return (BasePlateConfig) super.getConfig();
|
||||
}
|
||||
|
||||
enum SelectionMode{
|
||||
Samples,
|
||||
Pucks,
|
||||
None
|
||||
}
|
||||
SelectionMode selectionMode = SelectionMode.None;
|
||||
public SelectionMode getSelectionMode() {
|
||||
return selectionMode;
|
||||
}
|
||||
|
||||
public void setSelectionMode(SelectionMode selectionMode) {
|
||||
this.selectionMode = selectionMode;
|
||||
}
|
||||
|
||||
public Puck[] getPucks() {
|
||||
ArrayList<Puck> ret = new ArrayList<>();
|
||||
@@ -102,24 +82,20 @@ public class BasePlate extends DeviceBase {
|
||||
|
||||
|
||||
Puck getSelectedPuck(){
|
||||
if (selectionMode!=SelectionMode.None){
|
||||
for (Puck p:getPucks()){
|
||||
if (p.isSelected()){
|
||||
return p;
|
||||
}
|
||||
for (Puck p:getPucks()){
|
||||
if (p.isSelected()){
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Sample getSelectedSample(){
|
||||
if (selectionMode==SelectionMode.Samples){
|
||||
Puck puck = getSelectedPuck();
|
||||
if (puck != null){
|
||||
for (Sample s: puck.getSamples()){
|
||||
if (s.isSelected()){
|
||||
return s;
|
||||
}
|
||||
Puck puck = getSelectedPuck();
|
||||
if (puck != null){
|
||||
for (Sample s: puck.getSamples()){
|
||||
if (s.isSelected()){
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -173,87 +149,6 @@ public class BasePlate extends DeviceBase {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Rectangle plotRect = new Rectangle(0, 0, 0, 0);
|
||||
Rectangle boundingBox;
|
||||
|
||||
public Rectangle getPlotRect() {
|
||||
return plotRect;
|
||||
}
|
||||
|
||||
public Rectangle getBoundingBox() {
|
||||
return boundingBox;
|
||||
}
|
||||
|
||||
Color getBorderColor(boolean drawBackground) {
|
||||
//return new Color(32,32,32);
|
||||
if (drawBackground){
|
||||
return MainFrame.isDark() ? new Color(32,32,32) : Color.DARK_GRAY;
|
||||
}
|
||||
return MainFrame.isDark() ? new Color(0,32,0) : new Color(0,64,0);
|
||||
}
|
||||
|
||||
Color getColor() {
|
||||
return MainFrame.isDark() ? new Color(67,71,73) /*new Color(65,81,109)*/ : new Color(200, 204, 213);
|
||||
}
|
||||
|
||||
boolean drawContour;
|
||||
|
||||
|
||||
enum DrawMode{
|
||||
fill,
|
||||
center,
|
||||
left,
|
||||
right,
|
||||
top,
|
||||
bottom
|
||||
}
|
||||
|
||||
void draw(Graphics2D g, Rectangle plotRect, boolean drawSamples, boolean drawIds, boolean drawContour, DrawMode mode, BufferedImage img) {
|
||||
if (mode != DrawMode.fill){
|
||||
int length = Math.min(plotRect.width, plotRect.height);
|
||||
Point center= new Point(plotRect.x + plotRect.width/2, plotRect.y + plotRect.height/2); //center;
|
||||
switch (mode){
|
||||
case left:
|
||||
center.setLocation(length/2, center.y);
|
||||
break;
|
||||
case right:
|
||||
center.setLocation(plotRect.width - length/2, center.y);
|
||||
break;
|
||||
case top:
|
||||
center.setLocation(center.x, length/2);
|
||||
break;
|
||||
case bottom:
|
||||
center.setLocation(center.x, plotRect.height - length/2);
|
||||
break;
|
||||
}
|
||||
|
||||
plotRect = new Rectangle(center.x - length/2, center.y - length/2, length, length);
|
||||
}
|
||||
this.plotRect = plotRect;
|
||||
this.drawContour = drawContour;
|
||||
boundingBox = new Rectangle((int)(plotRect.x+plotRect.width*0.05), (int)(plotRect.y+plotRect.height * 0.05), (int)(plotRect.width*0.90), (int)(plotRect.height*0.90));
|
||||
if (img!=null){
|
||||
img = Utils.stretch(img, boundingBox.width, boundingBox.height);
|
||||
g.setClip(new Ellipse2D.Float(boundingBox.x, boundingBox.y, boundingBox.width, boundingBox.height));
|
||||
g.drawImage(img, boundingBox.x, boundingBox.y, null);
|
||||
}
|
||||
boolean drawBackground = (img==null);
|
||||
|
||||
if (drawContour){
|
||||
if (drawBackground){
|
||||
g.setColor(getColor());
|
||||
g.fillOval(boundingBox.x, boundingBox.y, boundingBox.width, boundingBox.height);
|
||||
}
|
||||
g.setColor(getBorderColor(drawBackground));
|
||||
g.drawOval(boundingBox.x, boundingBox.y, boundingBox.width, boundingBox.height);
|
||||
|
||||
}
|
||||
for (Puck puck : getPucks()) {
|
||||
puck.draw(g, null, drawSamples, drawIds, drawBackground, this) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void loadSample(Sample sample) throws Exception{
|
||||
|
||||
Reference in New Issue
Block a user