From 0226b6564b734774623704dbb5bdb261969f7e6e Mon Sep 17 00:00:00 2001 From: pompert <sdos@astron.nl> Date: Tue, 13 Jun 2006 12:54:55 +0000 Subject: [PATCH] BugID: 701 Improved handling of separate windows and legends. Supports multiple open viewers instead of one. --- .../lofar/sas/otb/util/plotter/PlotSlot.java | 8 +++ .../otb/util/plotter/PlotSlotViewFrame.java | 2 +- .../sas/otb/util/plotter/PlotSlotsPanel.java | 55 ++++++++++++++----- 3 files changed, 50 insertions(+), 15 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 0a87abc1e6d..dd8ad696921 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 @@ -50,6 +50,7 @@ public class PlotSlot extends JPanel{ private PlotPanel itsPlot; private String slotLabel; private boolean hasLegend; + private boolean isViewedExternally; private JLabel rightClickFacade; private LinkedList<PlotSlotListener> listenerList = null; private MouseAdapter plotMouseListener; @@ -92,6 +93,13 @@ public class PlotSlot extends JPanel{ public String getLabel(){ return slotLabel; } + protected void setViewedExternally(boolean viewedExternally){ + this.isViewedExternally = viewedExternally; + } + + protected boolean isViewedExternally(){ + return isViewedExternally; + } public PlotPanel getPlot(){ return itsPlot; } diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/plotter/PlotSlotViewFrame.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/plotter/PlotSlotViewFrame.java index 20773049153..79eef7b4411 100644 --- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/plotter/PlotSlotViewFrame.java +++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/plotter/PlotSlotViewFrame.java @@ -34,7 +34,7 @@ import nl.astron.lofar.java.gui.plotter.exceptions.PlotterException; */ public class PlotSlotViewFrame extends JDialog{ - int plotIndex; + protected int plotIndex; /** Creates a new instance of PlotSlotViewFrame */ public PlotSlotViewFrame(PlotSlotManager parent, int index, String title, boolean showLegendOnly) { 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 9239c15d8a3..146b80183ed 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.Color; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; @@ -31,10 +33,10 @@ import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; -import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuItem; -import javax.swing.JOptionPane; +import javax.swing.JPanel; import javax.swing.JPopupMenu; import org.apache.log4j.Logger; @@ -139,12 +141,32 @@ public class PlotSlotsPanel extends javax.swing.JPanel { gridBagConstraints.weighty = 1.0; gridBagConstraints.anchor = java.awt.GridBagConstraints.CENTER; PlotSlot newSlot = itsSlotManager.getSlot(i); - newSlot.addSlotListener(new SlotMouseAdapter()); - //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); + if(!newSlot.isViewedExternally()){ + newSlot.addSlotListener(new SlotMouseAdapter()); + //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); + }else{ + JPanel tempPanel = new JPanel(); + tempPanel.setBackground(Color.WHITE); + tempPanel.setLayout(new BorderLayout()); + tempPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); + tempPanel.setMinimumSize(new Dimension(getWidth()/columnsAndRows,getHeight()/columnsAndRows)); + tempPanel.setPreferredSize(new Dimension(getWidth()/columnsAndRows,getHeight()/columnsAndRows)); + tempPanel.add(new JLabel("External viewer active"),BorderLayout.CENTER); + JPanel northPanel = new JPanel(); + northPanel.setLayout(new BorderLayout()); + northPanel.setBackground(Color.LIGHT_GRAY); + JLabel slotNumber = new JLabel(""+i); + slotNumber.setForeground(Color.WHITE); + northPanel.add(slotNumber,BorderLayout.CENTER); + tempPanel.add(northPanel,BorderLayout.NORTH); + + slotsPanel.add(tempPanel,gridBagConstraints); + } + x++; if (x == columnsAndRows){ y++; @@ -267,12 +289,12 @@ public class PlotSlotsPanel extends javax.swing.JPanel { dialog.addWindowListener(new WindowListener(){ public void windowDeactivated(WindowEvent e){} public void windowActivated(WindowEvent e){} - public void windowClosed(WindowEvent e){ - rearrangeSlotGrid(); - externalLegendActive = false;} + public void windowClosed(WindowEvent e){} public void windowDeiconified(WindowEvent e){} public void windowIconified(WindowEvent e){} - public void windowClosing(WindowEvent e){} + public void windowClosing(WindowEvent e){ + externalLegendActive = false; + } public void windowOpened(WindowEvent e){} }); dialog.setVisible(true); @@ -329,10 +351,15 @@ public class PlotSlotsPanel extends javax.swing.JPanel { PlotSlotViewFrame dialog = new PlotSlotViewFrame(itsSlotManager,Integer.parseInt(selectedSlot.getLabel()),"Viewer for Plot "+selectedSlot.getLabel(),false); dialog.addWindowListener(new WindowListener(){ public void windowDeactivated(WindowEvent e){} - public void windowActivated(WindowEvent e){} + public void windowActivated(WindowEvent e){ + PlotSlotViewFrame sourceFrame = (PlotSlotViewFrame)e.getSource(); + itsSlotManager.getSlot(sourceFrame.plotIndex).setViewedExternally(true); + rearrangeSlotGrid();} public void windowClosed(WindowEvent e){ + PlotSlotViewFrame sourceFrame = (PlotSlotViewFrame)e.getSource(); + itsSlotManager.getSlot(sourceFrame.plotIndex).setViewedExternally(false); rearrangeSlotGrid(); - externalViewerActive = false;} + externalLegendActive = false;} public void windowDeiconified(WindowEvent e){} public void windowIconified(WindowEvent e){} public void windowClosing(WindowEvent e){} -- GitLab