From 3323f43d86e47f3f75a14f0250bc9d2359c49e66 Mon Sep 17 00:00:00 2001
From: pompert <sdos@astron.nl>
Date: Tue, 30 May 2006 15:01:37 +0000
Subject: [PATCH] 701 Additions: -Further implemented the plot panels to
 include (slowly working) slots and popupmenus

---
 .../lofar/sas/otb/util/plotter/PlotSlot.java  |  21 +-
 .../sas/otb/util/plotter/PlotSlotManager.java |   2 +-
 .../sas/otb/util/plotter/PlotSlotsPanel.form  |   3 +
 .../sas/otb/util/plotter/PlotSlotsPanel.java  |  84 ++++--
 .../sas/otbcomponents/ParmDBPlotPanel.form    | 173 ++++++-----
 .../sas/otbcomponents/ParmDBPlotPanel.java    | 276 +++++++++---------
 6 files changed, 313 insertions(+), 246 deletions(-)

diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/plotter/PlotSlot.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/plotter/PlotSlot.java
index 3c9d152d5c8..57fb037f3aa 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/plotter/PlotSlot.java
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/plotter/PlotSlot.java
@@ -26,7 +26,6 @@ package nl.astron.lofar.sas.otb.util.plotter;
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Dimension;
-import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.JTextArea;
 import nl.astron.lofar.java.gui.plotter.PlotConstants;
@@ -48,13 +47,13 @@ public class PlotSlot extends JPanel{
     /** Creates a new instance of PlotSlot */
     public PlotSlot() {
         itsPlotGroup = null;
-        itsPlot = new PlotPanel();
+        itsPlot = null;
         setLabel(EMPTY_SLOT);
-        setPreferredSize(new Dimension(320,240));
         setBackground(Color.WHITE);
-        
+        setBorder(javax.swing.BorderFactory.createEtchedBorder());
+        setSize(new Dimension(320,240));
+        setPreferredSize(new Dimension(320,240));
         setLayout(new BorderLayout());
-        
     }
     /** 
      * Creates a new instance of PlotSlot using a supplied label
@@ -75,19 +74,19 @@ public class PlotSlot extends JPanel{
         return slotLabel;
     }
     
-    public PlotPanel getPlot(){
-        return itsPlot;
-    }
-    
     public void setPlot(PlotPanel aPlot){
         itsPlot = aPlot;
     }
     
     public void addPlot(Object constraints){
         removeAll();
-        try {            
+        try {
+            if(itsPlot == null){
+                itsPlot = new PlotPanel();
+            }
             itsPlot.createPlot(PlotConstants.PLOT_XYLINE,true,constraints);
             add(itsPlot,BorderLayout.CENTER);
+           
         } catch (PlotterException ex) {
             JTextArea error = new JTextArea(ex.getMessage());
             error.setColumns(50);
@@ -145,7 +144,7 @@ public class PlotSlot extends JPanel{
         removePlot();
     }
     public boolean isEmpty(){
-        return containsPlot();
+        return !containsPlot();
     }
    
 }
diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/plotter/PlotSlotManager.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/plotter/PlotSlotManager.java
index 9c6b1658b87..a7678a480a3 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/plotter/PlotSlotManager.java
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/plotter/PlotSlotManager.java
@@ -97,7 +97,7 @@ public class PlotSlotManager{
     public int[] getAvailableSlotIndexes(){
         int[] availableSlots = null;
         availableSlots = new int[countAvailableSlots()];
-        int index = 1;
+        int index = 0;
         for(PlotSlot slot : itsPlotSlots){
             if(slot.isEmpty()){
                 availableSlots[index] = itsPlotSlots.indexOf(slot)+1;
diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/plotter/PlotSlotsPanel.form b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/plotter/PlotSlotsPanel.form
index c11257353af..383490febbe 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/plotter/PlotSlotsPanel.form
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/plotter/PlotSlotsPanel.form
@@ -13,6 +13,9 @@
   <SubComponents>
     <Container class="javax.swing.JPanel" name="slotsPanel">
       <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
         <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
           <Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
             <EtchetBorder/>
diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/plotter/PlotSlotsPanel.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/plotter/PlotSlotsPanel.java
index f43c10502ec..e79f22b4991 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/plotter/PlotSlotsPanel.java
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/plotter/PlotSlotsPanel.java
@@ -23,6 +23,8 @@
 
 package nl.astron.lofar.sas.otb.util.plotter;
 
+import java.awt.BorderLayout;
+import java.awt.Dimension;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import org.apache.log4j.Logger;
@@ -37,52 +39,85 @@ public class PlotSlotsPanel extends javax.swing.JPanel {
     static Logger logger = Logger.getLogger(PlotSlotsPanel.class);
     static String name = "PlotSlotsPanel";
     private PlotSlotManager itsSlotManager;
-    private int numberOfSlots;
-    
+      
     /** Creates new form BeanForm */
     public PlotSlotsPanel() {
         initComponents();
-        numberOfSlots = 4;
+        int numberOfSlots = 4;
         itsSlotManager = new PlotSlotManager(numberOfSlots);
-        
+        rearrangeSlotGrid();
+    }
+
+    /** adds a button to the BeanForm */
+    public void addPlotToSlot(int index,Object constraints) throws IllegalArgumentException{
+        if(itsSlotManager.isSlotAvailable(index)){
+            itsSlotManager.getSlot(index).addPlot(constraints);
+            rearrangeSlotGrid();
+        }else{
+            throw new IllegalArgumentException("A plot already exists in slot "+index);
+        }
+    }
+    
+    public int getAmountOfSlots(){
+        return itsSlotManager.getAmountOfSlots();
+    }
+    
+    public void setAmountOfSlots(int amount, boolean force) throws IllegalArgumentException{
+        itsSlotManager.setAmountOfSlots(amount,force);
+        rearrangeSlotGrid();
+    }
+    
+    public boolean isSlotAvailable(int index){
+        return itsSlotManager.isSlotAvailable(index);
+    }
+    
+    public int[] getAvailableSlotIndexes(){
+        return itsSlotManager.getAvailableSlotIndexes();
+    }
+    
+    private void rearrangeSlotGrid(){
+        slotsPanel.removeAll();
+        double squareRoot = Math.sqrt(Double.parseDouble(""+itsSlotManager.getAmountOfSlots()));
+        int columnsAndRows = Integer.parseInt(""+(int)squareRoot);
         GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
-            gridBagConstraints.gridwidth = itsSlotManager.getAmountOfSlots()/2;
-            gridBagConstraints.gridheight = itsSlotManager.getAmountOfSlots()/2;
+            gridBagConstraints.gridwidth = columnsAndRows;
+            gridBagConstraints.gridheight = columnsAndRows;
             gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
-            //gridBagConstraints.insets = new java.awt.Insets(2, 2, 0, 0);
+            gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 0);
         GridBagLayout layout = new GridBagLayout();
         layout.setConstraints(slotsPanel,gridBagConstraints);
-        
-        
+        //320,240 both!
+        slotsPanel.setSize(this.getSize());
+        slotsPanel.setMinimumSize(this.getSize());
+        //setSize(slotsPanel.getSize());
         logger.trace("getting "+itsSlotManager.getAmountOfSlots()+" slots from PlotSlotManager");
         int x = 0;
         int y = 0;
         for(int i = 1; i <= itsSlotManager.getAmountOfSlots(); i++){
-            
-            
-            logger.trace("Adding Slot to grid coordinate ("+x+","+y+")");
+            logger.trace("Setting Slot to grid coordinate ("+x+","+y+")");
             gridBagConstraints = new java.awt.GridBagConstraints();
             gridBagConstraints.gridx = x;
             gridBagConstraints.gridy = y;
-            //gridBagConstraints.gridwidth = itsSlotManager.getAmountOfSlots()/2;
-            //gridBagConstraints.gridheight = itsSlotManager.getAmountOfSlots()/2;
             gridBagConstraints.ipadx = 0;
             gridBagConstraints.ipady = 0;
-            gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
-            slotsPanel.add(itsSlotManager.getSlot(i),gridBagConstraints);
+            gridBagConstraints.weightx = 1.0;
+            gridBagConstraints.weighty = 1.0;
+            gridBagConstraints.anchor = java.awt.GridBagConstraints.CENTER;
+            PlotSlot newSlot = itsSlotManager.getSlot(i);
+            newSlot.setSize(new Dimension(getWidth()/columnsAndRows,getHeight()/columnsAndRows));
+            //
+            newSlot.setMinimumSize(new Dimension(getWidth()/columnsAndRows,getHeight()/columnsAndRows));
+            newSlot.setPreferredSize(new Dimension(getWidth()/columnsAndRows,getHeight()/columnsAndRows));
+            slotsPanel.add(newSlot,gridBagConstraints);            
             x++;
-            if (x == itsSlotManager.getAmountOfSlots()/2){
+            if (x == columnsAndRows){
                 y++;
                 x = 0;
             }
         }
-            
-    }
-
-    /** adds a button to the BeanForm */
-    public void addSlot(String label) {
-        //PlotSlot plotSlot = ne();
-    }
+        slotsPanel.validate();
+     }
+    
     /** This method is called from within the constructor to
      * initialize the form.
      * WARNING: Do NOT modify this code. The content of this method is
@@ -96,6 +131,7 @@ public class PlotSlotsPanel extends javax.swing.JPanel {
 
         slotsPanel.setLayout(new java.awt.GridBagLayout());
 
+        slotsPanel.setBackground(new java.awt.Color(255, 255, 255));
         slotsPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
         add(slotsPanel, java.awt.BorderLayout.CENTER);
 
diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/ParmDBPlotPanel.form b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/ParmDBPlotPanel.form
index 240a5424f37..2c06a226366 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/ParmDBPlotPanel.form
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/ParmDBPlotPanel.form
@@ -1,95 +1,124 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 
 <Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
-  <NonVisualComponents>
-    <Container class="javax.swing.JScrollPane" name="jScrollPane1">
-      <AuxValues>
-        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
-      </AuxValues>
-
-      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
-      <SubComponents>
-        <Component class="javax.swing.JTextArea" name="jTextArea1">
-          <Properties>
-            <Property name="columns" type="int" value="20"/>
-            <Property name="rows" type="int" value="5"/>
-          </Properties>
-        </Component>
-      </SubComponents>
-    </Container>
-  </NonVisualComponents>
   <AuxValues>
     <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
     <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
     <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
     <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
-    <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,-96,0,0,2,117"/>
+    <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,-95,0,0,3,-114"/>
   </AuxValues>
 
-  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
+  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
   <SubComponents>
-    <Component class="javax.swing.JButton" name="ParamCancelButton">
-      <Properties>
-        <Property name="text" type="java.lang.String" value="Cancel"/>
-        <Property name="enabled" type="boolean" value="false"/>
-      </Properties>
-      <Events>
-        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="ParamCancelButtonActionPerformed"/>
-      </Events>
+    <Container class="javax.swing.JPanel" name="contentPanel">
       <Constraints>
-        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
-          <GridBagConstraints gridX="2" gridY="3" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="30" insetsLeft="36" insetsBottom="7" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
-        </Constraint>
-      </Constraints>
-    </Component>
-    <Component class="javax.swing.JButton" name="ParamApplyButton">
-      <Properties>
-        <Property name="text" type="java.lang.String" value="Apply"/>
-        <Property name="enabled" type="boolean" value="false"/>
-      </Properties>
-      <Events>
-        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="ParamApplyButtonActionPerformed"/>
-      </Events>
-      <Constraints>
-        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
-          <GridBagConstraints gridX="3" gridY="3" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="30" insetsLeft="5" insetsBottom="7" insetsRight="9" anchor="18" weightX="0.0" weightY="0.0"/>
-        </Constraint>
-      </Constraints>
-    </Component>
-    <Component class="javax.swing.JLabel" name="jLabel1">
-      <Properties>
-        <Property name="horizontalAlignment" type="int" value="0"/>
-        <Property name="text" type="java.lang.String" value="ParmDB Plot Panel"/>
-      </Properties>
-      <Constraints>
-        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
-          <GridBagConstraints gridX="0" gridY="0" gridWidth="2" gridHeight="1" fill="0" ipadX="206" ipadY="5" insetsTop="10" insetsLeft="114" insetsBottom="0" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
-        </Constraint>
-      </Constraints>
-    </Component>
-    <Container class="javax.swing.JScrollPane" name="jScrollPane2">
-      <AuxValues>
-        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
-      </AuxValues>
-      <Constraints>
-        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
-          <GridBagConstraints gridX="0" gridY="2" gridWidth="4" gridHeight="1" fill="1" ipadX="588" ipadY="58" insetsTop="400" insetsLeft="10" insetsBottom="0" insetsRight="9" anchor="18" weightX="1.0" weightY="1.0"/>
+        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
+          <BorderConstraints direction="Center"/>
         </Constraint>
       </Constraints>
 
-      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
       <SubComponents>
-        <Component class="javax.swing.JTextArea" name="jTextArea2">
+        <Component class="javax.swing.JLabel" name="lSlotsAmount">
           <Properties>
-            <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
-              <Color blue="ee" green="ee" id="scrollbar" palette="3" red="ee" type="palette"/>
+            <Property name="horizontalAlignment" type="int" value="4"/>
+            <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
+              <ComponentRef name="cSlotsAmount"/>
             </Property>
-            <Property name="columns" type="int" value="20"/>
-            <Property name="editable" type="boolean" value="false"/>
-            <Property name="rows" type="int" value="5"/>
-            <Property name="text" type="java.lang.String" value="To zoom: Click and hold the left mouse button and select a rectangle.&#xa;To reset the zoom: Press CTRL-LeftMouseButton to reset the zoom.&#xa;To change colors/etc: Double-Click on a line in the legend.&#xa;To change plot/axis labels and tics/etc: Click on an axis or title and press the right mouse button."/>
+            <Property name="text" type="java.lang.String" value="Number of Slots"/>
           </Properties>
+          <Constraints>
+            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+              <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="2" insetsBottom="2" insetsRight="2" anchor="10" weightX="0.0" weightY="0.0"/>
+            </Constraint>
+          </Constraints>
         </Component>
+        <Component class="javax.swing.JComboBox" name="cSlotsAmount">
+          <Properties>
+            <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
+              <StringArray count="5">
+                <StringItem index="0" value="1"/>
+                <StringItem index="1" value="4"/>
+                <StringItem index="2" value="9"/>
+                <StringItem index="3" value="16"/>
+                <StringItem index="4" value="25"/>
+              </StringArray>
+            </Property>
+            <Property name="selectedIndex" type="int" value="1"/>
+          </Properties>
+          <Events>
+            <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="cSlotsAmountItemStateChanged"/>
+          </Events>
+          <Constraints>
+            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+              <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="2" insetsBottom="2" insetsRight="2" anchor="17" weightX="0.0" weightY="0.0"/>
+            </Constraint>
+          </Constraints>
+        </Component>
+        <Container class="javax.swing.JScrollPane" name="slotsPane">
+          <Properties>
+            <Property name="viewportBorder" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+              <Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
+                <EtchetBorder/>
+              </Border>
+            </Property>
+            <Property name="autoscrolls" type="boolean" value="true"/>
+            <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[640, 480]"/>
+            </Property>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[640, 480]"/>
+            </Property>
+          </Properties>
+          <Constraints>
+            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+              <GridBagConstraints gridX="0" gridY="1" gridWidth="2" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="2" insetsBottom="2" insetsRight="2" anchor="10" weightX="0.0" weightY="0.0"/>
+            </Constraint>
+          </Constraints>
+
+          <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+          <SubComponents>
+            <Component class="nl.astron.lofar.sas.otb.util.plotter.PlotSlotsPanel" name="itsSlotsPanel">
+              <Properties>
+                <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+                  <Dimension value="[640, 480]"/>
+                </Property>
+                <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+                  <Dimension value="[640, 480]"/>
+                </Property>
+              </Properties>
+            </Component>
+          </SubComponents>
+        </Container>
+        <Container class="javax.swing.JScrollPane" name="helpPane">
+          <AuxValues>
+            <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+          </AuxValues>
+          <Constraints>
+            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+              <GridBagConstraints gridX="0" gridY="2" gridWidth="2" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="2" insetsBottom="2" insetsRight="2" anchor="18" weightX="0.0" weightY="0.0"/>
+            </Constraint>
+          </Constraints>
+
+          <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+          <SubComponents>
+            <Component class="javax.swing.JTextArea" name="tHelp">
+              <Properties>
+                <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+                  <Color blue="ee" green="ee" id="Viewport.background" palette="3" red="ee" type="palette"/>
+                </Property>
+                <Property name="columns" type="int" value="20"/>
+                <Property name="editable" type="boolean" value="false"/>
+                <Property name="rows" type="int" value="5"/>
+                <Property name="text" type="java.lang.String" value="To zoom: Click and hold the left mouse button and select a rectangle.&#xa;To reset the zoom: Press CTRL-LeftMouseButton to reset the zoom.&#xa;To change colors/etc: Double-Click on a line in the legend.&#xa;To change plot/axis labels and tics/etc: Click on an axis or title and press the right mouse button."/>
+                <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+                  <Dimension value="[565, 75]"/>
+                </Property>
+              </Properties>
+            </Component>
+          </SubComponents>
+        </Container>
       </SubComponents>
     </Container>
   </SubComponents>
diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/ParmDBPlotPanel.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/ParmDBPlotPanel.java
index 904d1454fc0..8cd3d770996 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/ParmDBPlotPanel.java
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/ParmDBPlotPanel.java
@@ -7,7 +7,7 @@
 package nl.astron.lofar.sas.otbcomponents;
 
 import java.awt.Component;
-import java.awt.GridBagConstraints;
+import java.awt.Dimension;
 import java.util.Vector;
 import javax.swing.JMenuItem;
 import javax.swing.JOptionPane;
@@ -17,7 +17,6 @@ import nl.astron.lofar.sas.otb.SharedVars;
 import nl.astron.lofar.sas.otb.util.IViewPanel;
 import nl.astron.lofar.sas.otb.util.UserAccount;
 import nl.astron.lofar.sas.otb.util.jParmDBnode;
-import nl.astron.lofar.sas.otb.util.plotter.PlotSlotsPanel;
 import org.apache.log4j.Logger;
 
 /**
@@ -31,8 +30,7 @@ public class ParmDBPlotPanel extends javax.swing.JPanel implements IViewPanel{
     
     private MainFrame  itsMainFrame;
     private String itsParamName;
-    private PlotSlotsPanel itsSlotsPanel;
-    
+        
     /** Creates new form BeanForm based upon aParameter
      *
      * @params  aParam   Param to obtain the info from
@@ -49,24 +47,13 @@ public class ParmDBPlotPanel extends javax.swing.JPanel implements IViewPanel{
     /** Creates new form BeanForm */
     public ParmDBPlotPanel() {
         initComponents();
-        itsSlotsPanel = new PlotSlotsPanel();
-        
-        GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
-        gridBagConstraints.gridx = 0;
-        gridBagConstraints.gridy = 1;
-        gridBagConstraints.gridwidth = 2;
-        gridBagConstraints.ipadx = 2;
-        gridBagConstraints.ipady = 0;
-        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
-        gridBagConstraints.insets = new java.awt.Insets(1, 1, 0, 0);
-        add(itsSlotsPanel, gridBagConstraints);
         
     }
     
     public void setMainFrame(MainFrame aMainFrame) {
         if (aMainFrame != null) {
             itsMainFrame=aMainFrame;
-            
+           
             
         } else {
             logger.debug("No Mainframe supplied");
@@ -74,7 +61,7 @@ public class ParmDBPlotPanel extends javax.swing.JPanel implements IViewPanel{
     }
     
     public boolean hasPopupMenu() {
-        return false;
+        return true;
     }
     
     
@@ -96,10 +83,21 @@ public class ParmDBPlotPanel extends javax.swing.JPanel implements IViewPanel{
      *  aPopupMenu.show(aComponent, x, y );        
      */
     public void createPopupMenu(Component aComponent,int x, int y) {
-        JPopupMenu aPopupMenu=null;
-        JMenuItem  aMenuItem=null;
-        
-        //  Fill in menu as in the example above        
+       // build up the menu
+       JPopupMenu aPopupMenu = new JPopupMenu();
+       int[] availableSlots = itsSlotsPanel.getAvailableSlotIndexes();
+       for(int i = 0; i < availableSlots.length; i++){
+           JMenuItem aMenuItem=new JMenuItem("Add to slot "+availableSlots[i]);
+           aMenuItem.addActionListener(new java.awt.event.ActionListener() {
+               public void actionPerformed(java.awt.event.ActionEvent evt) {
+                   popupMenuHandler(evt);
+               }
+           });
+           aMenuItem.setActionCommand("Add to slot " +availableSlots[i]);
+           aPopupMenu.add(aMenuItem);
+           aPopupMenu.setOpaque(true);
+       }
+       aPopupMenu.show(aComponent, x, y );     
     }
     
     /** handles the choice from the popupmenu 
@@ -111,37 +109,27 @@ public class ParmDBPlotPanel extends javax.swing.JPanel implements IViewPanel{
      *      }  
      */
     public void popupMenuHandler(java.awt.event.ActionEvent evt) {
+        logger.debug("PopUp menu Selection made: "+evt.getActionCommand().toString());
+        int slotSelected = Integer.parseInt(evt.getActionCommand().toString().substring(12));
+        logger.debug("Plot Slot extrapolated: "+slotSelected);
+        itsSlotsPanel.addPlotToSlot(slotSelected,constructPlotterConstraints(itsParamName));
     }
     
-    private void initPanel(String aParamName) {
-        // check access
-        UserAccount userAccount = itsMainFrame.getUserAccount();
-        
-        // For now:
-        // give enabled/disabled fields here, can be changed later to choices stored in the database
-        
-        if(userAccount.isAdministrator()) {
-            // enable/disable certain controls
-        }
-        if(userAccount.isAstronomer()) {
-            // enable/disable certain controls
-        }
-        if(userAccount.isInstrumentScientist()) {
-            // enable/disable certain controls
-        }       
-        
+    private Object constructPlotterConstraints(String aParamName){
+        String[] passToDataAccess = null; 
         if (aParamName != null) {
-            if(aParamName.equalsIgnoreCase("ParmDB")){
-                itsParamName = "*";
+            String cloneParamName = aParamName.toString();
+            if(cloneParamName.equalsIgnoreCase("ParmDB")){
+                cloneParamName = "*";
             }else{
-                itsParamName=aParamName.substring(7);
-                itsParamName += "*";
+                cloneParamName=cloneParamName.substring(7);
+                cloneParamName += "*";
             }
             try{
-                String[] passToDataAccess = new String[7];
+                passToDataAccess = new String[7];
                 
                 Vector paramValues;
-                paramValues = SharedVars.getJParmFacade().getRange(itsParamName);
+                paramValues = SharedVars.getJParmFacade().getRange(cloneParamName);
                 double startx = Double.parseDouble(paramValues.get(0).toString());
                 double endx =Double.parseDouble(paramValues.get(1).toString());
                 double starty = Double.parseDouble(paramValues.get(2).toString());
@@ -149,7 +137,7 @@ public class ParmDBPlotPanel extends javax.swing.JPanel implements IViewPanel{
                 int numx = Integer.parseInt("5");
                 int numy = Integer.parseInt("5");
                 
-                passToDataAccess[0] = itsParamName;
+                passToDataAccess[0] = cloneParamName;
                 passToDataAccess[1] = ""+startx;
                 passToDataAccess[2] = ""+endx;
                 passToDataAccess[3] = ""+numx;
@@ -165,6 +153,26 @@ public class ParmDBPlotPanel extends javax.swing.JPanel implements IViewPanel{
         } else {
             logger.debug("ERROR:  no Param Name given");
         }
+        return passToDataAccess;
+    }
+    
+    
+    private void initPanel(String aParamName) {
+        // check access
+        UserAccount userAccount = itsMainFrame.getUserAccount();
+        
+        // For now:
+        // give enabled/disabled fields here, can be changed later to choices stored in the database
+        
+        if(userAccount.isAdministrator()) {
+            // enable/disable certain controls
+        }
+        if(userAccount.isAstronomer()) {
+            // enable/disable certain controls
+        }
+        if(userAccount.isInstrumentScientist()) {
+            // enable/disable certain controls
+        }       
     }
     public void setParam(String aParam) {
         if (aParam != null) {
@@ -174,25 +182,6 @@ public class ParmDBPlotPanel extends javax.swing.JPanel implements IViewPanel{
             logger.debug("No param supplied");
         }
     }
-    
-    /** Enables/disables the buttons
-     *
-     * @param   enabled     true/false enabled/disabled
-     */
-    public void enableButtons(boolean enabled) {
-        this.ParamApplyButton.setEnabled(enabled);
-        this.ParamCancelButton.setEnabled(enabled);
-    }
-    
-    /** Sets the buttons visible/invisible
-     *
-     * @param   visible     true/false visible/invisible
-     */
-    public void setButtonsVisible(boolean visible) {
-        this.ParamApplyButton.setVisible(visible);
-        this.ParamCancelButton.setVisible(visible);
-    }
-    
     /** Enables/disables the complete form
      *
      * @param   enabled     true/false enabled/disabled
@@ -207,8 +196,16 @@ public class ParmDBPlotPanel extends javax.swing.JPanel implements IViewPanel{
     public void setContent(Object anObject) {
         jParmDBnode node = (jParmDBnode)anObject;
         itsParamName = node.nodeID();
-        
-        initPanel(itsParamName);
+        logger.trace("ParmDB name selected : "+itsParamName);
+        int panelWidth = itsMainFrame.getWidth();
+        int panelHeight = itsMainFrame.getHeight();
+        slotsPane.setMinimumSize(new Dimension(640,480));
+        slotsPane.setPreferredSize(new Dimension(panelWidth-400,panelHeight-300));
+        slotsPane.setSize(new Dimension(panelWidth-400,panelHeight-300));
+        slotsPane.getViewport().setPreferredSize(new Dimension(640,480));
+        itsSlotsPanel.setMinimumSize(new Dimension(640,480));
+        itsSlotsPanel.setPreferredSize(new Dimension(panelWidth-440,panelHeight-340));
+        //initPanel(itsParamName);
     }
     
     private void saveInput() {
@@ -218,6 +215,22 @@ public class ParmDBPlotPanel extends javax.swing.JPanel implements IViewPanel{
         
     }
     
+    /** Enables/disables the buttons
+     *
+     * @param   enabled     true/false enabled/disabled
+     */
+    public void enableButtons(boolean enabled) {
+        
+    }
+    
+    /** Sets the buttons visible/invisible
+     *
+     * @param   visible     true/false visible/invisible
+     */
+    public void setButtonsVisible(boolean visible) {
+        
+    }
+    
     /** This method is called from within the constructor to
      * initialize the form.
      * WARNING: Do NOT modify this code. The content of this method is
@@ -227,102 +240,89 @@ public class ParmDBPlotPanel extends javax.swing.JPanel implements IViewPanel{
     private void initComponents() {
         java.awt.GridBagConstraints gridBagConstraints;
 
-        jScrollPane1 = new javax.swing.JScrollPane();
-        jTextArea1 = new javax.swing.JTextArea();
-        ParamCancelButton = new javax.swing.JButton();
-        ParamApplyButton = new javax.swing.JButton();
-        jLabel1 = new javax.swing.JLabel();
-        jScrollPane2 = new javax.swing.JScrollPane();
-        jTextArea2 = new javax.swing.JTextArea();
+        contentPanel = new javax.swing.JPanel();
+        lSlotsAmount = new javax.swing.JLabel();
+        cSlotsAmount = new javax.swing.JComboBox();
+        slotsPane = new javax.swing.JScrollPane();
+        itsSlotsPanel = new nl.astron.lofar.sas.otb.util.plotter.PlotSlotsPanel();
+        helpPane = new javax.swing.JScrollPane();
+        tHelp = new javax.swing.JTextArea();
 
-        jTextArea1.setColumns(20);
-        jTextArea1.setRows(5);
-        jScrollPane1.setViewportView(jTextArea1);
+        setLayout(new java.awt.BorderLayout());
 
-        setLayout(new java.awt.GridBagLayout());
-
-        ParamCancelButton.setText("Cancel");
-        ParamCancelButton.setEnabled(false);
-        ParamCancelButton.addActionListener(new java.awt.event.ActionListener() {
-            public void actionPerformed(java.awt.event.ActionEvent evt) {
-                ParamCancelButtonActionPerformed(evt);
-            }
-        });
+        contentPanel.setLayout(new java.awt.GridBagLayout());
 
+        lSlotsAmount.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
+        lSlotsAmount.setLabelFor(cSlotsAmount);
+        lSlotsAmount.setText("Number of Slots");
         gridBagConstraints = new java.awt.GridBagConstraints();
-        gridBagConstraints.gridx = 2;
-        gridBagConstraints.gridy = 3;
-        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
-        gridBagConstraints.insets = new java.awt.Insets(30, 36, 7, 0);
-        add(ParamCancelButton, gridBagConstraints);
+        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
+        contentPanel.add(lSlotsAmount, gridBagConstraints);
 
-        ParamApplyButton.setText("Apply");
-        ParamApplyButton.setEnabled(false);
-        ParamApplyButton.addActionListener(new java.awt.event.ActionListener() {
-            public void actionPerformed(java.awt.event.ActionEvent evt) {
-                ParamApplyButtonActionPerformed(evt);
+        cSlotsAmount.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "4", "9", "16", "25" }));
+        cSlotsAmount.setSelectedIndex(1);
+        cSlotsAmount.addItemListener(new java.awt.event.ItemListener() {
+            public void itemStateChanged(java.awt.event.ItemEvent evt) {
+                cSlotsAmountItemStateChanged(evt);
             }
         });
 
         gridBagConstraints = new java.awt.GridBagConstraints();
-        gridBagConstraints.gridx = 3;
-        gridBagConstraints.gridy = 3;
-        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
-        gridBagConstraints.insets = new java.awt.Insets(30, 5, 7, 9);
-        add(ParamApplyButton, gridBagConstraints);
+        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
+        contentPanel.add(cSlotsAmount, gridBagConstraints);
+
+        slotsPane.setViewportBorder(javax.swing.BorderFactory.createEtchedBorder());
+        slotsPane.setAutoscrolls(true);
+        slotsPane.setMinimumSize(new java.awt.Dimension(640, 480));
+        slotsPane.setPreferredSize(new java.awt.Dimension(640, 480));
+        itsSlotsPanel.setMinimumSize(new java.awt.Dimension(640, 480));
+        itsSlotsPanel.setPreferredSize(new java.awt.Dimension(640, 480));
+        slotsPane.setViewportView(itsSlotsPanel);
 
-        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
-        jLabel1.setText("ParmDB Plot Panel");
         gridBagConstraints = new java.awt.GridBagConstraints();
         gridBagConstraints.gridx = 0;
-        gridBagConstraints.gridy = 0;
+        gridBagConstraints.gridy = 1;
         gridBagConstraints.gridwidth = 2;
-        gridBagConstraints.ipadx = 206;
-        gridBagConstraints.ipady = 5;
-        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
-        gridBagConstraints.insets = new java.awt.Insets(10, 114, 0, 0);
-        add(jLabel1, gridBagConstraints);
+        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
+        contentPanel.add(slotsPane, gridBagConstraints);
 
-        jTextArea2.setBackground(javax.swing.UIManager.getDefaults().getColor("scrollbar"));
-        jTextArea2.setColumns(20);
-        jTextArea2.setEditable(false);
-        jTextArea2.setRows(5);
-        jTextArea2.setText("To zoom: Click and hold the left mouse button and select a rectangle.\nTo reset the zoom: Press CTRL-LeftMouseButton to reset the zoom.\nTo change colors/etc: Double-Click on a line in the legend.\nTo change plot/axis labels and tics/etc: Click on an axis or title and press the right mouse button.");
-        jScrollPane2.setViewportView(jTextArea2);
+        tHelp.setBackground(javax.swing.UIManager.getDefaults().getColor("Viewport.background"));
+        tHelp.setColumns(20);
+        tHelp.setEditable(false);
+        tHelp.setRows(5);
+        tHelp.setText("To zoom: Click and hold the left mouse button and select a rectangle.\nTo reset the zoom: Press CTRL-LeftMouseButton to reset the zoom.\nTo change colors/etc: Double-Click on a line in the legend.\nTo change plot/axis labels and tics/etc: Click on an axis or title and press the right mouse button.");
+        tHelp.setMinimumSize(new java.awt.Dimension(565, 75));
+        helpPane.setViewportView(tHelp);
 
         gridBagConstraints = new java.awt.GridBagConstraints();
         gridBagConstraints.gridx = 0;
         gridBagConstraints.gridy = 2;
-        gridBagConstraints.gridwidth = 4;
-        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
-        gridBagConstraints.ipadx = 588;
-        gridBagConstraints.ipady = 58;
+        gridBagConstraints.gridwidth = 2;
+        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
-        gridBagConstraints.weightx = 1.0;
-        gridBagConstraints.weighty = 1.0;
-        gridBagConstraints.insets = new java.awt.Insets(400, 10, 0, 9);
-        add(jScrollPane2, gridBagConstraints);
+        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
+        contentPanel.add(helpPane, gridBagConstraints);
+
+        add(contentPanel, java.awt.BorderLayout.CENTER);
 
     }// </editor-fold>//GEN-END:initComponents
-    
-    private void ParamApplyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ParamApplyButtonActionPerformed
-        saveInput();
-    }//GEN-LAST:event_ParamApplyButtonActionPerformed
-    
-    private void ParamCancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ParamCancelButtonActionPerformed
-        initPanel(itsParamName);
-    }//GEN-LAST:event_ParamCancelButtonActionPerformed
-    
+
+    private void cSlotsAmountItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cSlotsAmountItemStateChanged
+        itsSlotsPanel.setAmountOfSlots(Integer.parseInt(evt.getItem().toString()),false);
+    }//GEN-LAST:event_cSlotsAmountItemStateChanged
+            
     
     
     // Variables declaration - do not modify//GEN-BEGIN:variables
-    private javax.swing.JButton ParamApplyButton;
-    private javax.swing.JButton ParamCancelButton;
-    private javax.swing.JLabel jLabel1;
-    private javax.swing.JScrollPane jScrollPane1;
-    private javax.swing.JScrollPane jScrollPane2;
-    private javax.swing.JTextArea jTextArea1;
-    private javax.swing.JTextArea jTextArea2;
+    private javax.swing.JComboBox cSlotsAmount;
+    private javax.swing.JPanel contentPanel;
+    private javax.swing.JScrollPane helpPane;
+    private nl.astron.lofar.sas.otb.util.plotter.PlotSlotsPanel itsSlotsPanel;
+    private javax.swing.JLabel lSlotsAmount;
+    private javax.swing.JScrollPane slotsPane;
+    private javax.swing.JTextArea tHelp;
     // End of variables declaration//GEN-END:variables
     
     /**
-- 
GitLab