package osp; import java.awt.geom.Point2D; import java.util.Observable; import jsky.coords.DMS; import jsky.coords.HMS; import jsky.coords.WorldCoords; /** * Class representing a slit on the mask. * Slits are numbered to 0 to 54 in soft, * to 1 to 55 in display and files. * The 1st and 55th slits can't be affected but positioned if joined */ public class Slit extends Observable { // Attributes // ----------- /** Maximal position of the slit in arc sec*/ public double PosMax = 2.0 * 60.0; /** Minimal position of the slit in arc sec */ public double PosMin = -2.0 * 60.0; /** Default position of the slit *in arc sec */ public double PosDef = 0.0; /** Maximum slit aperture in arc sec */ public double ApeMax = 30.0; /** Minimum slit aperture in arc sec */ public double ApeMin = 0.0; /** Default slit aperture */ public double ApeDef; /** Coordinates of the slit */ private Point2D.Double posXY = new Point2D.Double(); /** Coordinates of the slit center */ private Point2D.Double posCenter = new Point2D.Double(); private WorldCoords centerSlitWc = new WorldCoords(); /** Slit world coordinates */ private HMS alphaSlit; private DMS deltaSlit; public boolean fSkyCoord=false; /** Id of the slit */ private int id; /** slit position from the center axe of th mask*/ private double position; /** slit aperture */ private double aperture; private boolean isJoined; private int joinedReferenceSlitId; private int affectedObject = -1; // Constructors // -------------- /** * Constructs a new slit with the default position and aperture. * * @param i * Id of the slit */ public Slit(int i) { id = i; position = PosDef; aperture = ApeMin; isJoined=false; joinedReferenceSlitId=-1; } // Methods // --------- /** * Notifies observers of changes. */ public void update() { setChanged(); notifyObservers(); } /** * Returns the id of the slit. * * @return Number of the slit */ public int getId() { return id; } /** * Sets the position of the slit. * * @param pos * Position of the slit. */ public void setPosition(double pos) { position = pos; } public void setSkyPosition(HMS alpha, DMS delta) { alphaSlit=alpha; deltaSlit=delta; fSkyCoord=true; } // /** Return the slit center ra */ // public HMS getAlpha() { // // return alphaSlit; // } // /** Return the slit center dec */ // public DMS getDelta() { // // return deltaSlit; // } /** * Returns the position of the slit. * * @return Position of the slit. */ public double getPosition() { return position; } /** * Changes slits aperture default value */ public void setSlitDefaultAperture(double defValue) { ApeDef=defValue; } /** * Reinit the aperture of the slit * to the default value */ public void setToDefaultAperture() { aperture = ApeDef; } /** * Sets the aperture of the slit. * * @param ape * Aperture of the slit */ public void setAperture(double ape) { aperture = ape; } /** * Returns the aperture of the slit. * * @return Aperture of the slit */ public double getAperture() { return aperture; } /** * Sets the XY position of the slit in the space. * * @param xy * Coordinates of the slit */ public void setPosXY(Point2D.Double xy) { posXY = xy; } /** * Sets the XY position of the slit in the space. * * @param x * X coordinate of the slit * @param y * Y coordinate of the slit */ public void setPosXY(double x, double y) { posXY.x = x; posXY.y = y; } /** * Returns the XY coordinates of the slit in space. * * @return XY position of the slit */ public Point2D.Double getPosXY() { return posXY; } /** * Returns the X coordinate of the slit in space. * * @return X position of the slit */ public double getPosX() { return posXY.x; } /** * Returns the Y coordinate of the slit in space. * * @return Y position of the slit */ public double getPosY() { return posXY.y; } /** * Sets the object affected to the slit. A value of -1 means there is no * affected object. * * @param num * Number of the affected object, -1 if there is no affected * object */ public void setAffectedObject(int num) { affectedObject = num; } /** * Returns the number of object affected to the slit. A value of -1 means * there is no affected object. * * @return Number of the affected object or -1 if there is no affected * object */ public int getAffectedObject() { return affectedObject; } // ADD May 2018 // /** Position slit center */ public Point2D.Double getPosCenter() { return posCenter; } public void setPosCenter(Point2D.Double posCenter) { this.posCenter = posCenter; } /** WC Position slit center */ public WorldCoords getWcPosCenter() { return centerSlitWc; } public void setWcPosCenter(Point2D.Double wcPosCenter) { this.centerSlitWc = new WorldCoords(wcPosCenter.getX(),wcPosCenter.getY()); fSkyCoord=true; } public boolean isJoined() { return (isJoined); } /** Flag if the slit is joined **/ public void setIsJoined(boolean b) { isJoined=b; } /** Set reference slit id to actual slit joined to **/ public void setJoinedRefSlit(int k) { // TODO Auto-generated method stub joinedReferenceSlitId=k; } /** Get reference slit id to actual slit joined to **/ public int getJoinedRefSlit() { return joinedReferenceSlitId; } }