Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

DisplayPanel.java

00001 package DisplayGUI;
00002 
00003 import java.awt.*;
00004 import java.awt.event.*;
00005 import java.awt.image.*;
00006 import javax.swing.*;
00007 import java.awt.Graphics2D.*;
00008 import java.awt.geom.*;
00009 import java.util.*;
00010 import GuiComponents.System.*;
00011 
00012 public class DisplayPanel extends JPanel implements guiInterface, TestDataInfo  {
00013         gui guiControl;
00014 
00015         FontMetrics metrics;
00016                 int maxWidth;
00017         private int displayOption=0; // for testdata 0:rod 1: sctdb 2: rod-sctdb comparison
00018 
00019         private JMenu dataPopupMenu, sctdbPopupMenu;
00020 
00021         private Rectangle draggedRectangle;
00022         
00023         private boolean firstTime = true;
00024                 private Rectangle area;
00025         private Dimension dim;
00026 
00027         private ModuleCell redCell,lastClickedCell,popupCell;
00028         private String mouseLocationText, mouseLocationSN;
00029                 private int lastClickedRodSlot=-1;
00030 
00031         private DisplayTitle leftTitle, middleTitle, rightTitle, optionTitle;
00032 
00033         ConfigurationInterface config;
00034 
00035         private java.util.List changedModuleList;
00036 
00037     public DisplayPanel(gui parent){
00038         guiControl=parent;
00039         setBackground(Color.white);
00040         addMouseMotionListener(this);
00041         addMouseListener(this);
00042         dim = getSize();
00043         maxWidth = (int)dim.getWidth();
00044 
00045         setMinimumSize(new Dimension(14*boxWidth,yOffSet+58*boxHeight));
00046         setPreferredSize(new Dimension(14*boxWidth,yOffSet+58*boxHeight));
00047 
00048         config = ConfigurationInterface.getInstance();
00049         config.setWindowSize(maxWidth,(int)dim.getHeight());
00050 
00051         leftTitle = null;
00052         middleTitle = null;
00053         rightTitle = null;
00054         optionTitle=null;
00055 
00056         changedModuleList = new ArrayList();
00057 
00058 
00059     }
00060 
00061     
00062 
00063 
00064     // Handles the event of the user pressing down the mouse button.
00065     public void mousePressed(MouseEvent e){
00066         if(guiControl.displayStatus.getStatus()!=DisplayStatus.MODULE_GROUP_SELECTION) return;
00067                 if(guiControl.selectorPane.getDisplayParameterIndex()>0) return; // must be first parameter in configParams list
00068         draggedRectangle = new Rectangle(new Point(e.getX(),e.getY()));   
00069     }
00070 
00071     // Handles the event of a user dragging the mouse while holding
00072     // down the mouse button.
00073     public void mouseDragged(MouseEvent e){
00074 
00075  
00076         if(guiControl.displayStatus.getStatus()!=DisplayStatus.MODULE_GROUP_SELECTION) return;
00077         if(guiControl.selectorPane.getDisplayParameterIndex()>0) return; // must be first parameter in configParams list
00078         redCell=null;
00079         int width = e.getX() - (int)draggedRectangle.getX();
00080         int height = e.getY() - (int)draggedRectangle.getY();
00081         int thisModuleGroup = guiControl.selectorPane.getMouseClickIndex();
00082 // re-define or resize the dragged rectangle
00083         if(width<0 || height<0) {
00084              int oldWidth = (int)draggedRectangle.getWidth();
00085              int oldHeight = (int)draggedRectangle.getHeight();
00086              draggedRectangle = new Rectangle(new Point(e.getX(),e.getY()),new Dimension(Math.abs(width)+oldWidth,Math.abs(height)+oldHeight));
00087              }
00088         else draggedRectangle.setSize(new Dimension(width,height));
00089 
00090                 config = ConfigurationInterface.getInstance();
00091                 int viewCategoryIndex = guiControl.selectorPane.getViewCategoryIndex();
00092         for (java.util.Iterator m = config.getSerialNumberList(viewCategoryIndex,guiControl.selectorPane.getViewIndex()).iterator(); m.hasNext(); ) {
00093                String thisSN=(String)m.next();
00094                ModuleCell thisCell = config.getModuleCell(thisSN);
00095                if(thisCell.getPolygon(viewCategoryIndex).intersects(draggedRectangle)) {
00096                    switch(e.getModifiers()) {
00097                      case InputEvent.BUTTON2_MASK:
00098                      case InputEvent.BUTTON3_MASK:
00099                      if(thisCell.getModuleGroup()==thisModuleGroup) {
00100                            thisCell.setModuleGroup(-1);
00101                            changedModuleList.add(thisCell);
00102                            }
00103                      break;
00104                    default:
00105                        if(!thisCell.isSelected()) {
00106                               thisCell.setModuleGroup(thisModuleGroup);
00107                               changedModuleList.add(thisCell);
00108                               }
00109                      }
00110                }
00111           }
00112         if(guiControl.displayStatus.getStatus()==DisplayStatus.MODULE_GROUP_SELECTION && guiControl.selectorPane.getDisplayParameterIndex()==0) setDisplayColors();
00113 
00114                 repaint();
00115 
00116     }
00117 
00118     // Handles the event of a user releasing the mouse button.
00119     public void mouseReleased(MouseEvent e){
00120        if(draggedRectangle!=null) {
00121            draggedRectangle=null;
00122            repaint();
00123            }
00124        if(guiControl.displayStatus.getStatus()==DisplayStatus.MODULE_GROUP_SELECTION && guiControl.selectorPane.getDisplayParameterIndex()==0 && changedModuleList.size()>0) {
00125            guiControl.tablesDisplayPane.updateTables();
00126            ConfigurationInterface.getInstance().updateModuleGroups(changedModuleList);
00127            changedModuleList.clear();
00128            }
00129     }
00130        
00131      // This method is required by MouseListener.
00132      public void mouseMoved(MouseEvent e){
00133        if(draggedRectangle!=null) return;
00134 
00135            config = ConfigurationInterface.getInstance();
00136 
00137        ModuleCell thisCell = config.getCell(guiControl.selectorPane.getViewCategoryIndex(),guiControl.selectorPane.getViewIndex(),e.getX(),e.getY());
00138        if(thisCell==null) {
00139            redCell = null;
00140            if(mouseLocationText!=null) {
00141                mouseLocationText = null;
00142                mouseLocationSN=null;
00143                repaint();
00144            }
00145            return;
00146        }
00147 
00148 // check for redCell
00149        if(thisCell==redCell)  return;  // no change
00150        else {
00151 //            if(redCell!=null) redCell.setSelected(false);
00152 //            thisCell.setSelected(true);
00153             redCell = thisCell;
00154        }
00155 // update mouse Text
00156        String sn = thisCell.getSerialNo();
00157        String infoString = sn+" ("+config.getSNInfo(sn,SNInfo.ROD_CRATE)+","+config.getSNInfo(sn,SNInfo.ROD_NUMBER)+","+config.getSNInfo(sn,SNInfo.ROD_CHANNEL)+","+config.getSNInfo(sn,SNInfo.DCS_CRATE)+","+config.getSNInfo(sn,SNInfo.DCS_CHANNEL)+") ";
00158        switch(guiControl.displayStatus.getStatus()) {
00159           case DisplayStatus.IS_MONITOR:
00160                if(guiControl.tablesDisplayPane.getTestSelection()!=null && thisCell.getData()!=null) {
00161                  mouseLocationText = new String(infoString+" : "+thisCell.getData().intValue());
00162                  }
00163                break;
00164           case DisplayStatus.MODULE_GROUP_SELECTION:
00165                         if(guiControl.selectorPane.getDisplayParameterIndex()>0) { // BOC parameter
00166                         ColorScale thisColorScale = guiControl.colorScalePane.getColorScale();
00167                         if(thisColorScale!=null) mouseLocationText = new String(infoString+" : "+thisColorScale.getLabel(thisCell.getData()));
00168                         else mouseLocationText = new String(infoString+" : No Data");
00169                                 }
00170                         else { // module group
00171                         if(guiControl.selectorPane.getViewIndex()<4) mouseLocationText = new String(infoString+" MUR: "+thisCell.getMUR()+" Position: "+thisCell.getModulePosition());
00172                         else mouseLocationText = new String(infoString+" MUR: "+thisCell.getMUR()+" Quad/Pos: "+thisCell.getQuadrant()+"/"+thisCell.getEndCapPosition());
00173                         }
00174                            break;
00175           default:  
00176                ColorScale thisColorScale = guiControl.colorScalePane.getColorScale();
00177                if(thisColorScale!=null) mouseLocationText = new String(infoString+" : "+thisColorScale.getLabel(thisCell.getData()));
00178                else mouseLocationText = new String(infoString+" : No Data");
00179                break;
00180           }
00181 
00182 
00183        repaint();
00184      }
00185 
00186      // These methods are required by MouseMotionListener.
00187      public void mouseClicked(MouseEvent e){
00188 
00189            config = ConfigurationInterface.getInstance();
00190        ModuleCell thisCell = config.getCell(guiControl.selectorPane.getViewCategoryIndex(),guiControl.selectorPane.getViewIndex(),e.getX(),e.getY());
00191        if(thisCell==null) {
00192           switch(e.getModifiers()) {
00193            case InputEvent.BUTTON2_MASK:
00194            case InputEvent.BUTTON3_MASK:
00195 
00196            if(guiControl.selectorPane.getViewCategoryIndex()==ConfigurationInterface.RODCRATE_VIEWS) {
00197                                 int viewIndex = guiControl.selectorPane.getViewIndex();
00198                                 lastClickedRodSlot = config.getRodSlotNumber(viewIndex,e);
00199                                 switch(lastClickedRodSlot) {
00200                                         case -1: guiControl.menuActions.showPopupMenu(e); break;
00201                                         case 13: guiControl.menuActions.showTIMRegisterMenu(e); break;
00202                                         default:
00203                                                 if(config.getASerialNumberForSlot(guiControl.selectorPane.getViewIndex(),lastClickedRodSlot)!=null) guiControl.menuActions.showRODMenu(e);
00204                                                 else guiControl.menuActions.showPopupMenu(e);
00205                                         }
00206                                 }
00207            else guiControl.menuActions.showPopupMenu(e); // general display popup menu, not specific to a module
00208            break;
00209           default:
00210           }
00211          return;
00212         }
00213        
00214        lastClickedCell = thisCell;
00215 
00216        switch(guiControl.displayStatus.getStatus()) {
00217 
00218          case DisplayStatus.MODULE_GROUP_SELECTION:
00219 
00220                         if(guiControl.selectorPane.getDisplayParameterIndex()>0) { // BOC config parameters
00221 
00222                         guiControl.tablesDisplayPane.resultsTable.setSelectedSerialNo(thisCell.getSerialNo(),true);
00223                         switch(e.getModifiers()) {
00224                         case InputEvent.BUTTON2_MASK:
00225                         case InputEvent.BUTTON3_MASK:
00226                                 popupCell=thisCell;
00227                                 JPopupMenu pMenu = guiControl.guiMenus.getMenu(GuiMenus.MODULE_BOC).getPopupMenu();
00228                                 pMenu.show(e.getComponent(),e.getX(),e.getY());
00229                                 pMenu.setInvoker(guiControl.guiMenus.getMenu(GuiMenus.MODULE_BOC));
00230                         break;
00231                         default:
00232                                 }
00233 
00234                                 }
00235 
00236                         else { // module group
00237 
00238                 int thisModuleGroup =guiControl.selectorPane.getMouseClickIndex();
00239                 switch(e.getModifiers()) {
00240                         case InputEvent.BUTTON2_MASK:
00241                         case InputEvent.BUTTON3_MASK:
00242                         if(thisCell.getModuleGroup()==thisModuleGroup) {
00243                                 thisCell.setModuleGroup(-1);
00244                                 changedModuleList.add(thisCell);
00245                                 }
00246                         break;
00247                         default:
00248                         if(!thisCell.isSelected()) {
00249                                 thisCell.setModuleGroup(thisModuleGroup);
00250                             changedModuleList.add(thisCell);
00251                             }
00252                         }
00253 
00254                         repaint();
00255 
00256                         if(changedModuleList.size()>0) {
00257                         guiControl.tablesDisplayPane.updateTables();
00258                         config.updateModuleGroups(changedModuleList);
00259                         changedModuleList.clear();
00260                         }
00261 
00262                           }
00263            break;
00264 
00265        case DisplayStatus.IS_MONITOR:
00266            guiControl.tablesDisplayPane.listISObjects(thisCell);
00267            guiControl.tablesDisplayPane.resultsTable.setSelectedSerialNo(thisCell.getSerialNo(),false);
00268            switch(e.getModifiers()) {
00269                case InputEvent.BUTTON2_MASK:
00270                case InputEvent.BUTTON3_MASK:
00271                   popupCell=thisCell;
00272                    JPopupMenu pMenu = guiControl.guiMenus.getMenu(GuiMenus.MODULE_DATA_MANAGER).getPopupMenu();
00273                    pMenu.show(e.getComponent(),e.getX(),e.getY());
00274                    pMenu.setInvoker(guiControl.guiMenus.getMenu(GuiMenus.MODULE_DATA_MANAGER));
00275                break;
00276               default:
00277            }
00278            break;
00279        case DisplayStatus.TEST_DATA:
00280            guiControl.tablesDisplayPane.resultsTable.setSelectedSerialNo(thisCell.getSerialNo(),true);
00281            switch(e.getModifiers()) {
00282                case InputEvent.BUTTON2_MASK:
00283                case InputEvent.BUTTON3_MASK:
00284                   popupCell=thisCell;
00285                    JPopupMenu pMenu = guiControl.guiMenus.getMenu(GuiMenus.MODULE_RESULTS).getPopupMenu();
00286                    pMenu.show(e.getComponent(),e.getX(),e.getY());
00287                    pMenu.setInvoker(guiControl.guiMenus.getMenu(GuiMenus.MODULE_RESULTS));
00288                break;
00289               default:
00290            }
00291            break;
00292        case DisplayStatus.SCTDB_DATA:
00293        case DisplayStatus.SCTDB_RODDAQ_DATA:
00294            guiControl.tablesDisplayPane.resultsTable.setSelectedSerialNo(thisCell.getSerialNo(),true);
00295            switch(e.getModifiers()) {
00296                case InputEvent.BUTTON2_MASK:
00297                case InputEvent.BUTTON3_MASK:
00298                   popupCell=thisCell;
00299                     JPopupMenu pMenu = guiControl.guiMenus.getMenu(GuiMenus.MODULE_SCTDB).getPopupMenu();
00300                    pMenu.show(e.getComponent(),e.getX(),e.getY());
00301                    pMenu.setInvoker(guiControl.guiMenus.getMenu(GuiMenus.MODULE_SCTDB));
00302                    break;
00303                 default:
00304                 }
00305                break;
00306        case DisplayStatus.IV_DATA:
00307            guiControl.tablesDisplayPane.resultsTable.setSelectedSerialNo(thisCell.getSerialNo(),true);
00308            switch(e.getModifiers()) {
00309                case InputEvent.BUTTON2_MASK:
00310                case InputEvent.BUTTON3_MASK:
00311                   popupCell=thisCell;
00312                     JPopupMenu pMenu = guiControl.guiMenus.getMenu(GuiMenus.MODULE_IVSCAN).getPopupMenu();
00313                    pMenu.show(e.getComponent(),e.getX(),e.getY());
00314                    pMenu.setInvoker(guiControl.guiMenus.getMenu(GuiMenus.MODULE_IVSCAN));
00315                break;
00316               default:
00317            }
00318                 break;
00319         case DisplayStatus.DCS_DATA:
00320                 guiControl.tablesDisplayPane.resultsTable.setSelectedSerialNo(thisCell.getSerialNo(),true);
00321                 switch(e.getModifiers()) {
00322                 case InputEvent.BUTTON2_MASK:
00323                 case InputEvent.BUTTON3_MASK:
00324                         popupCell=thisCell;
00325                     JPopupMenu pMenu = guiControl.guiMenus.getMenu(GuiMenus.MODULE_DCS).getPopupMenu();
00326                         pMenu.show(e.getComponent(),e.getX(),e.getY());
00327                         pMenu.setInvoker(guiControl.guiMenus.getMenu(GuiMenus.MODULE_DCS));
00328                         break;
00329                 default:
00330                 }
00331 
00332 
00333                 break;
00334         case DisplayStatus.PROBE_DATA:
00335            guiControl.tablesDisplayPane.resultsTable.setSelectedSerialNo(thisCell.getSerialNo(),true);
00336            switch(e.getModifiers()) {
00337                 case InputEvent.BUTTON2_MASK:
00338                 case InputEvent.BUTTON3_MASK:
00339                         popupCell=thisCell;
00340                     JPopupMenu pMenu = guiControl.guiMenus.getMenu(GuiMenus.MODULE_PROBE).getPopupMenu();
00341                         pMenu.show(e.getComponent(),e.getX(),e.getY());
00342                         pMenu.setInvoker(guiControl.guiMenus.getMenu(GuiMenus.MODULE_PROBE));
00343                         break;
00344                 default:
00345                                 }
00346 
00347 
00348                 break;
00349                 default:
00350             guiControl.tablesDisplayPane.resultsTable.setSelectedSerialNo(thisCell.getSerialNo(),true);
00351         }
00352        
00353        }
00354 
00355      public void mouseExited(MouseEvent e){}
00356      public void mouseEntered(MouseEvent e){}
00357                          
00358 
00359      public void refreshDisplay(){
00360         redCell=null;
00361                 repaint();
00362         }
00363 
00364     public void initPanelParameters() {  //must do this because config needs the panel size before it is painted
00365             dim = getSize();
00366             maxWidth = (int)dim.getWidth();
00367             ConfigurationInterface.getInstance().setWindowSize(maxWidth,(int)dim.getHeight());
00368             }
00369 
00370 
00371     public void paintComponent(Graphics g){
00372 
00373         super.paintComponent(g);
00374 
00375         Graphics2D g2 = (Graphics2D)g;
00376                 g2.setStroke(new BasicStroke(1.0f));
00377 
00378         if ( firstTime ) {
00379 //            dim = getSize();
00380             area = new Rectangle(dim);
00381 //            maxWidth = (int)dim.getWidth();
00382             firstTime = false;
00383             g2.setFont(displayTextFont);
00384             metrics = g2.getFontMetrics();
00385 //            config.setWindowSize(maxWidth,(int)dim.getHeight());
00386         }
00387         // Clears the rectangle that was previously drawn.
00388         g2.setPaint(Color.white);
00389         g2.fill(area);
00390 
00391         
00392         ConfigurationInterface.getInstance().drawViewOutline(g2,guiControl.selectorPane.getViewCategoryIndex(),guiControl.selectorPane.getViewIndex());
00393         drawTitle(g2);
00394         if(mouseLocationText!=null) drawMouseLocation(g2,mouseLocationText);
00395         drawGraphicsCells(g2);
00396         drawMouseSelections(g2);
00397 
00398     }
00399 
00400 
00401     
00402     public void drawGraphicsCells(Graphics2D g2) {
00403         ColorScale thisColorScale = guiControl.colorScalePane.getColorScale();
00404           config = ConfigurationInterface.getInstance();
00405           int viewCategoryIndex = guiControl.selectorPane.getViewCategoryIndex();
00406           switch(viewCategoryIndex) {
00407                 case ConfigurationInterface.RODCRATE_VIEWS:
00408                         for (java.util.Iterator m = config.getSerialNumberList(viewCategoryIndex,guiControl.selectorPane.getViewIndex()).iterator(); m.hasNext(); ) {
00409                         String thisSN=(String)m.next();
00410                         ModuleCell thisCell = config.getModuleCell(thisSN);
00411                         g2.setPaint(thisCell.getColor());
00412                                 java.awt.Polygon thisP = thisCell.getPolygon(viewCategoryIndex);
00413                         g2.fill(thisCell.getPolygon(viewCategoryIndex));
00414                         g2.setColor(Color.black);
00415                         g2.draw(thisCell.getPolygon(viewCategoryIndex));
00416                         }
00417                         break;
00418                 case ConfigurationInterface.SCT_VIEWS:
00419                         if(guiControl.selectorPane.getViewIndex()<4) {
00420                         for (java.util.Iterator m = config.getSerialNumberList(viewCategoryIndex,guiControl.selectorPane.getViewIndex()).iterator(); m.hasNext(); ) {
00421                         String thisSN=(String)m.next();
00422                         ModuleCell thisCell = config.getModuleCell(thisSN);
00423                         g2.setPaint(thisCell.getColor());
00424                         g2.fill(thisCell.getPolygon(viewCategoryIndex));
00425                         g2.setColor(Color.black);
00426                         g2.draw(thisCell.getPolygon(viewCategoryIndex));
00427                         }
00428                         }
00429                         else {
00430           // for endcaps, must draw/paint middle ring first
00431                         for (java.util.Iterator m = config.getSerialNumberList(guiControl.selectorPane.getViewCategoryIndex(),guiControl.selectorPane.getViewIndex()).iterator(); m.hasNext(); ) {
00432                String thisSN=(String)m.next();
00433                ModuleCell thisCell = config.getModuleCell(thisSN);
00434                int ring = thisCell.getPosition();
00435                if(ring<13 || ring>22) continue;
00436                g2.setPaint(thisCell.getColor());
00437                g2.fill(thisCell.getPolygon(viewCategoryIndex));
00438                g2.setColor(Color.black);
00439                g2.draw(thisCell.getPolygon(viewCategoryIndex));
00440                }
00441          for (java.util.Iterator m = config.getSerialNumberList(guiControl.selectorPane.getViewCategoryIndex(),guiControl.selectorPane.getViewIndex()).iterator(); m.hasNext(); ) {
00442                String thisSN=(String)m.next();
00443                ModuleCell thisCell = config.getModuleCell(thisSN);
00444                int ring = thisCell.getPosition();
00445                if(ring>=13 && ring<=22) continue;
00446                g2.setPaint(thisCell.getColor());
00447                g2.fill(thisCell.getPolygon(viewCategoryIndex));
00448                g2.setColor(Color.black);
00449                g2.draw(thisCell.getPolygon(viewCategoryIndex));
00450                }
00451            }
00452             break;
00453             default:
00454             }
00455     }
00456 
00457    public void drawMouseSelections(Graphics2D g2) {
00458                 if(redCell!=null) {
00459             g2.setColor(Color.red);
00460             g2.draw(redCell.getPolygon(guiControl.selectorPane.getViewCategoryIndex()));
00461                 }
00462         if(draggedRectangle!=null) {
00463             g2.setColor(Color.red);
00464             g2.draw(draggedRectangle);
00465                 }
00466         g2.setColor(Color.lightGray);
00467         }
00468 
00469 
00470 
00471     public void drawMouseLocation(Graphics2D g2, String mouseLocationText) {
00472         g2.setFont(displayTextFont);
00473 //        g2.setPaint(darkBlueColor);
00474         g2.setPaint(Color.white);
00475         metrics = g2.getFontMetrics();
00476         int stringWidth = metrics.stringWidth(mouseLocationText);
00477         int stringHeight = metrics.getHeight();
00478         g2.drawString(mouseLocationText,maxWidth/2+7*boxWidth - stringWidth-5,yOffSet+boxHeight-stringHeight);
00479     }
00480 
00481     public void drawTitle(Graphics2D g2) {
00482         g2.setPaint(Color.blue);
00483         int leftX = maxWidth/2-6*boxWidth;
00484         int rightX = maxWidth/2+7*boxWidth;
00485         Rectangle top = new Rectangle(leftX,0,13*boxWidth,yOffSet);
00486         g2.fill(top);
00487         leftX+=5;
00488 
00489         // left Title
00490         if(leftTitle!=null) leftTitle.drawText(g2, leftX, 0);
00491 
00492         // right Title
00493         int rightTitleWidth= 0;
00494         if(rightTitle!=null) rightTitleWidth = rightTitle.drawText(g2,rightX-5,1);
00495 
00496         // middle Title
00497         if(middleTitle!=null) middleTitle.drawText(g2,rightX-rightTitleWidth-20,1);
00498 
00499         g2.setFont(displayTextFont);
00500         g2.setPaint(Color.white);
00501         int y =yOffSet+boxHeight-g2.getFontMetrics().getHeight();
00502 
00503                 String viewName = guiControl.selectorPane.getViewName();
00504                 int sWidth=0;
00505                 if(viewName!=null) {
00506                 g2.drawString(viewName,leftX,y);
00507                 sWidth = g2.getFontMetrics().stringWidth(viewName);
00508                         }
00509 
00510 //        if(optionTitle!=null) optionTitle.drawCenteredText(g2,maxWidth/2-20,yOffSet+boxHeight);
00511         if(optionTitle!=null) g2.drawString(optionTitle.title,leftX+20+sWidth,y);
00512     }
00513 
00514 
00515     public void setDisplayOption(int displayOption) {
00516         this.displayOption=displayOption;
00517         guiControl.colorScalePane.setColorScale();
00518         setDisplayColors();
00519         refreshDisplay();
00520         guiControl.tablesDisplayPane.listTestResults();
00521         }
00522    public int getDisplayOption() {
00523         return displayOption;
00524         }
00525    public void resetDisplayOption() {
00526         displayOption=0;
00527         }
00528    public ModuleCell getLastClickedCell() {
00529         return lastClickedCell;
00530         }
00531         public int getLastClickedRodSlot() {
00532                 return lastClickedRodSlot;
00533                 }
00534     public void setLastClickedCell(String sn) {
00535                 lastClickedCell = ConfigurationInterface.getInstance().getModuleCell(sn);
00536                 }
00537 
00538     public void setDisplayColors() {
00539 //       System.out.println("**setDisplayColors**");
00540        TestSelection testSelection = guiControl.tablesDisplayPane.getTestSelection();
00541        IVTestSelection ivTestSelection = guiControl.tablesDisplayPane.getIVTestSelection();
00542        int testIndex = (testSelection!=null) ? testSelection.getTestIndex() : -1;
00543 
00544        int displayStatus = guiControl.displayStatus.getStatus();
00545        Map countMap = null;
00546        if(displayStatus==DisplayStatus.IS_MONITOR && testSelection!=null) countMap = guiControl.isInterface.isCounter.getModuleMap(guiControl.selectorPane.getDisplayParameterIndex(),testSelection.getRunScanRegex(),testSelection.isRetrievedData());
00547        Map dcsMap = null;
00548 //       if(displayStatus==DisplayStatus.DCS_DATA && guiControl.tablesDisplayPane.getTestControlObjectName()!=null) dcsMap=guiControl.isInterface.getDCSMap(guiControl.tablesDisplayPane.getTestControlObjectName());
00549        if(guiControl.tablesDisplayPane.getTestControlObjectName()!=null) dcsMap=guiControl.isInterface.getDCSMap(guiControl.tablesDisplayPane.getTestControlObjectName());
00550        int parameterIndex = guiControl.selectorPane.getDisplayParameterIndex();
00551        int mouseOption = guiControl.selectorPane.getMouseClickIndex();
00552 
00553        SummaryReader.DCSInfo dcsInfo;
00554 
00555            config = ConfigurationInterface.getInstance();
00556 
00557 // enumerate through all modules
00558         MODULELOOP:
00559         for (java.util.Iterator m = config.getSerialNumberList(guiControl.selectorPane.getViewCategoryIndex(),guiControl.selectorPane.getViewIndex()).iterator(); m.hasNext(); ) {
00560             String sn=(String)m.next();
00561             ModuleCell thisCell = config.getModuleCell(sn);
00562                 Double theData=null;
00563                 String header=null;
00564                 switch(displayStatus) {
00565 
00566                 case DisplayStatus.TEST_DATA:
00567                         if(testSelection!=null) header = testSelection.getResultObjectHeader();
00568                         if(header==null) {
00569                         fillCellData(thisCell,null);
00570                         continue MODULELOOP;
00571                         }
00572                         dcsInfo = (dcsMap!=null) ? (SummaryReader.DCSInfo)dcsMap.get(sn) : null;
00573                         switch(displayOption) {
00574                         case 1: // SCTDB Data only
00575                                 header = testSelection.getSCTDBObjectHeader();
00576                                 if((theData = guiControl.isInterface.getSCTDBData(header+sn,testIndex))==null) {
00577                                 fillCellData(thisCell,null);
00578                                 continue MODULELOOP;
00579                                 }
00580                                 break;
00581                         case 2: // Compare SCTDB and ROD data
00582                                 if((theData=guiControl.isInterface.getTestData(header,sn,testIndex,dcsInfo))==null) {
00583                                 fillCellData(thisCell,null);
00584                                 continue MODULELOOP;
00585                                 }
00586                                 Double sctdbData;
00587                                 if((sctdbData = guiControl.isInterface.getSCTDBData(testSelection.getSCTDBObjectHeader()+sn,testIndex))==null) {
00588                                 fillCellData(thisCell,null);
00589                                 continue MODULELOOP;
00590                                 }
00591                                 double diff = Math.abs(theData.doubleValue()-sctdbData.doubleValue());
00592                                 if(testIndex==TEST_FULLBYPASS && parameterIndex>2) theData=new Double(1.0);
00593                                 else theData = (diff>testDataTolerances[testIndex][parameterIndex]) ? new Double(2.0) : new Double(1.0);
00594                                 break;
00595                                 case 0: // ROD Data only
00596                                 default:
00597                                 if((theData=guiControl.isInterface.getTestData(header,sn,testIndex,dcsInfo))==null) {
00598                                 fillCellData(thisCell,null);
00599                                 continue MODULELOOP;
00600                                 }
00601                         }
00602 
00603                                         break;
00604 
00605                 case DisplayStatus.IV_DATA:
00606                         if(ivTestSelection==null) {
00607                         fillCellData(thisCell,null);
00608                         continue MODULELOOP;
00609                         }
00610                         header = ivTestSelection.getResultObjectHeader();
00611                         if(header==null || (theData = guiControl.isInterface.getTestData(header,thisCell.getSerialNo(),TEST_IV,null))==null) {
00612                         fillCellData(thisCell,null);
00613                         continue MODULELOOP;
00614                         }
00615                         break;
00616 
00617                 case DisplayStatus.SCTDB_DATA:
00618                         if(testSelection==null) {
00619                         fillCellData(thisCell,null);
00620                         continue MODULELOOP;
00621                         }
00622                         header = testSelection.getSCTDBObjectHeader();
00623                         if(header==null || (theData = guiControl.isInterface.getSCTDBData(header+thisCell.getSerialNo(),testIndex))==null) {
00624                         fillCellData(thisCell,null);
00625                         continue MODULELOOP;
00626                         }
00627                         break;
00628 
00629                 case DisplayStatus.SCTDB_RODDAQ_DATA:
00630                         if(testSelection==null) {
00631                         fillCellData(thisCell,null);
00632                         continue MODULELOOP;
00633                         }
00634                         header = testSelection.getSCTDBRodDaqObjectHeader();
00635                         if(header==null || (theData = guiControl.isInterface.getSCTDBData(header+thisCell.getSerialNo(),testIndex))==null) {
00636                         fillCellData(thisCell,null);
00637                         continue MODULELOOP;
00638                         }
00639                         break;
00640 
00641                 case DisplayStatus.DCS_DATA:
00642                         if((theData=guiControl.isInterface.getDCSData(sn,parameterIndex))==null) {
00643                         fillCellData(thisCell,null);
00644                         continue MODULELOOP;
00645                         }
00646                         break;
00647 
00648                 case DisplayStatus.PROBE_DATA:
00649                                 theData = SctApiInfo.getInstance().getProbeData(sn,mouseOption);
00650                         break;
00651 
00652                 case DisplayStatus.IS_MONITOR:
00653                         if(testSelection==null || countMap==null) {
00654                         fillCellData(thisCell,null);
00655                         continue MODULELOOP;
00656                         }
00657                     theData = (countMap.containsKey(sn)) ? new Double(((java.util.List)countMap.get(sn)).size()) : new Double(0.);
00658                         break;
00659 
00660                 case DisplayStatus.MODULE_GROUP_SELECTION:
00661                                 if(parameterIndex>0) theData = SctApiInfo.getInstance().getProbeData(sn,mouseOption);
00662                         else theData = new Double(thisCell.getModuleGroup());
00663                 default:
00664                         fillCellData(thisCell,null);
00665                         }
00666                 fillCellData(thisCell,theData);
00667                 }
00668 // now define titles
00669                 int displayedTestIndex = guiControl.isInterface.getListFilterIndex();
00670         int selectedTestIndex = (testSelection!=null) ? testSelection.getTestIndex() : -1;
00671         int runno = (testSelection!=null) ? testSelection.getRunNo() : -1;
00672         int scanno = (testSelection!=null) ? testSelection.getScanNo() : -1;
00673         String statusString="No Data";
00674         String runScanString="No Data";
00675         String dataDescription = guiControl.selectorPane.getDisplayParameter();
00676         String option = guiControl.selectorPane.getOption();
00677 
00678         leftTitle = new DisplayTitle(DisplayStatus.statusNames[displayStatus],java.awt.Color.yellow,displayTitleFont);
00679         middleTitle = (dataDescription!=null) ? new DisplayTitle(dataDescription, java.awt.Color.white,displayTitleFont) : null;
00680         rightTitle=null;
00681       optionTitle=(option!=null) ? new DisplayTitle(option,java.awt.Color.white,displayTextFont) : null;
00682 
00683         switch(displayStatus) {
00684                 case DisplayStatus.TEST_DATA:
00685                 switch(displayOption) {
00686                         case 0:
00687                         rightTitle = (runno!=-1) ? new DisplayTitle("Run "+Integer.toString(runno)+" Scan "+Integer.toString(scanno),java.awt.Color.yellow,displayTitleFont) : new DisplayTitle("No Data",java.awt.Color.red,displayTitleFont);
00688                         break;
00689                         case 1:
00690                         rightTitle = new DisplayTitle("SctDaq Reference",java.awt.Color.red,displayTitleFont);
00691                         break;
00692                         case 2:
00693                         rightTitle = new DisplayTitle("SctDaq Comparison",java.awt.Color.red,displayTitleFont);
00694                         default:
00695                         }
00696                 break;
00697             case DisplayStatus.IV_DATA:
00698                 rightTitle = (ivTestSelection!=null) ? new DisplayTitle("Run "+Integer.toString(ivTestSelection.getRunNo())+" Scan "+Integer.toString(ivTestSelection.getScanNo()),java.awt.Color.yellow,displayTitleFont) :  new DisplayTitle("No Data",java.awt.Color.red,displayTitleFont);
00699                 leftTitle = new DisplayTitle("IV Scans",java.awt.Color.yellow,displayTitleFont);
00700                 middleTitle = (ivTestSelection!=null) ? new DisplayTitle(guiControl.selectorPane.getIVParameter(),java.awt.Color.white,displayTitleFont) : null;
00701                 break;
00702             case DisplayStatus.SCTDB_DATA:
00703                 statusString="SCTDAQ Reference Data";
00704                 if(selectedTestIndex>=0) statusString=testMenuNames[selectedTestIndex];
00705                 else if(displayedTestIndex>=0) statusString=testMenuNames[displayedTestIndex];
00706                 leftTitle = new DisplayTitle(statusString,java.awt.Color.yellow,displayTitleFont);
00707                 rightTitle= (runno!=-1) ? new DisplayTitle("SCTDAQ Reference",java.awt.Color.red,displayTitleFont) : new DisplayTitle("No Data",java.awt.Color.red,displayTitleFont);
00708                 break;
00709             case DisplayStatus.SCTDB_RODDAQ_DATA:
00710                 rightTitle = (runno!=-1) ? new DisplayTitle("Run "+Integer.toString(runno)+" Scan "+Integer.toString(scanno),java.awt.Color.yellow,displayTitleFont) : new DisplayTitle("No Data",java.awt.Color.red,displayTitleFont);
00711                 break;
00712             case DisplayStatus.PROBE_DATA:
00713                 leftTitle= new DisplayTitle("Module Probe Data",java.awt.Color.yellow,displayTitleFont);
00714                 middleTitle = null;
00715                 break;
00716             case DisplayStatus.IS_MONITOR:
00717                 rightTitle = (runno!=-1) ? new DisplayTitle("Run "+Integer.toString(runno)+" Scan "+Integer.toString(scanno),java.awt.Color.yellow,displayTitleFont) : new DisplayTitle("No Data",java.awt.Color.red,displayTitleFont);
00718                 break;
00719             case DisplayStatus.MODULE_GROUP_SELECTION:
00720                 if(parameterIndex==0) middleTitle= (option!=null) ? new DisplayTitle(option+" Count : "+Integer.toString(guiControl.tablesDisplayPane.resultsTable.getRowCount()),java.awt.Color.white,displayTitleFont) : null;
00721                 break;
00722             default:
00723             }
00724 
00725    }
00726 
00727     private void fillCellData(ModuleCell thisCell, Double theData) {
00728          if(theData==null) {
00729             thisCell.setData(null,java.awt.Color.white);
00730             return;
00731             }
00732          ColorScale thisColorScale;
00733          if((thisColorScale = guiControl.colorScalePane.getColorScale())!=null) thisCell.setData(theData,thisColorScale.getColor(theData));
00734          else thisCell.setData(null,java.awt.Color.white);
00735          }
00736 
00737 
00738 
00739 
00740 
00741 
00742  
00743 }

Generated on Fri Dec 16 19:46:17 2005 for SCT DAQ/DCS Software - Java by doxygen 1.3.5