LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  March 2015

HPS-SVN March 2015

Subject:

r2264 - in /java/trunk/users/src/main/java/org/hps/users/kmccarty/triggerdiagnostics/ui: AbstractTablePanel.java EfficiencyTablePanel.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Thu, 5 Mar 2015 18:26:15 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (188 lines)

Author: [log in to unmask]
Date: Thu Mar  5 10:26:10 2015
New Revision: 2264

Log:
Updated the AbstractTablePanel class to support both horizontal and vertical component alignments. This allows for the EfficiencyTablePanel to be displayed in a manner that will fit reasonably into a component.

Modified:
    java/trunk/users/src/main/java/org/hps/users/kmccarty/triggerdiagnostics/ui/AbstractTablePanel.java
    java/trunk/users/src/main/java/org/hps/users/kmccarty/triggerdiagnostics/ui/EfficiencyTablePanel.java

Modified: java/trunk/users/src/main/java/org/hps/users/kmccarty/triggerdiagnostics/ui/AbstractTablePanel.java
 =============================================================================
--- java/trunk/users/src/main/java/org/hps/users/kmccarty/triggerdiagnostics/ui/AbstractTablePanel.java	(original)
+++ java/trunk/users/src/main/java/org/hps/users/kmccarty/triggerdiagnostics/ui/AbstractTablePanel.java	Thu Mar  5 10:26:10 2015
@@ -26,15 +26,24 @@
 public abstract class AbstractTablePanel extends JPanel implements DiagnosticUpdatable {
 	// Static variables.
 	private static final long serialVersionUID = 0L;
+	public static final int ORIENTATION_HORIZONTAL = 0;
+	public static final int ORIENTATION_VERTICAL   = 1;
 	
 	// Components.
+	private JLabel localHeader;
+	private JLabel globalHeader;
 	protected final JTable localTable;
-	private JLabel localHeader;
 	protected final JTable globalTable;
-	private JLabel globalHeader;
+	
+	// Component parameters.
+	private boolean horizontal = true;
+	private Dimension userPrefSize = null;
 	private Dimension defaultPrefSize = new Dimension(0, 0);
-	private Dimension userPrefSize = null;
-	
+	
+	/**
+	 * Instantiates an <code>AbstractTablePanel</code>.
+	 * @param args Arguments to be usd when generating the panel tables.
+	 */
 	public AbstractTablePanel(Object... args) {
 		// Initialize the tables.
 		JTable[] tables = initializeTables(args);
@@ -130,6 +139,28 @@
 		}
 	}
 	
+	/**
+	 * Sets the orientation of components on the panel.
+	 * @param orientation - The orientation identifier. Identifiers can
+	 * be obtained as static variables from the within the root object
+	 * <code>AbstractTable</code>.
+	 */
+	public void setOrientation(int orientation) {
+		if(orientation == ORIENTATION_HORIZONTAL) {
+			if(!horizontal) {
+				horizontal = true;
+				positionComponents();
+			}
+		} else if(orientation == ORIENTATION_VERTICAL) {
+			if(horizontal) {
+				horizontal = false;
+				positionComponents();
+			}
+		} else {
+			throw new IllegalArgumentException("Invalid orienation identifier.");
+		}
+	}
+	
 	@Override
 	public void setPreferredSize(Dimension preferredSize) {
 		userPrefSize = preferredSize;
@@ -154,35 +185,63 @@
 		// Do not update if the components have not been initialized.
 		if(localHeader == null) { return; }
 		
-		// The local components get the left half of the panel and the
-		// global components the right. Find half of the panel width,
-		// accounting for the internal spacing. This is an internal
-		// component, so it does not employ additional spacing between
-		// itself and the parent component's edges.
-		int compWidth = (getWidth() - 10) / 2;
-		
-		// If there is any width remaining, it goes to the spacing.
-		int horizontal = ComponentUtils.hinternal + (getWidth() - 10) % 2;
-		
-		// Place the header labels. These are given their preferred
-		// height. Note that this means a very small panel may cut off
-		// some of the components. First, get the preferred height of
-		// the label with the larger preferred height. These should be
-		// the same thing, but just in case...
-		int labelHeight = localHeader.getPreferredSize().height;
-		if(labelHeight < globalHeader.getPreferredSize().height) {
-			labelHeight = globalHeader.getPreferredSize().height;
-		}
-		
-		// Set the label sizes and positions.
-		localHeader.setBounds(0, 0, compWidth, labelHeight);
-		globalHeader.setLocation(ComponentUtils.getNextX(localHeader, horizontal), 0);
-		globalHeader.setSize(compWidth, labelHeight);
-		
-		// The tables go under their respective labels and should fill
-		// the remainder of the label height.
-		int tableY = ComponentUtils.getNextY(localHeader, ComponentUtils.vinternal);
-		localTable.setBounds(0, tableY, compWidth, localTable.getPreferredSize().height);
-		globalTable.setBounds(globalHeader.getX(), tableY, compWidth, globalTable.getPreferredSize().height);
+		// If the components should be position horizontally...
+		if(horizontal) {
+			// The local components get the left half of the panel and the
+			// global components the right. Find half of the panel width,
+			// accounting for the internal spacing. This is an internal
+			// component, so it does not employ additional spacing between
+			// itself and the parent component's edges.
+			int compWidth = (getWidth() - 10) / 2;
+			
+			// If there is any width remaining, it goes to the spacing.
+			int horizontal = ComponentUtils.hinternal + (getWidth() - 10) % 2;
+			
+			// Place the header labels. These are given their preferred
+			// height. Note that this means a very small panel may cut off
+			// some of the components. First, get the preferred height of
+			// the label with the larger preferred height. These should be
+			// the same thing, but just in case...
+			int labelHeight = localHeader.getPreferredSize().height;
+			if(labelHeight < globalHeader.getPreferredSize().height) {
+				labelHeight = globalHeader.getPreferredSize().height;
+			}
+			
+			// Set the label sizes and positions.
+			localHeader.setBounds(0, 0, compWidth, labelHeight);
+			globalHeader.setLocation(ComponentUtils.getNextX(localHeader, horizontal), 0);
+			globalHeader.setSize(compWidth, labelHeight);
+			
+			// The tables go under their respective labels and should fill
+			// the remainder of the label height.
+			int tableY = ComponentUtils.getNextY(localHeader, ComponentUtils.vinternal);
+			localTable.setBounds(0, tableY, compWidth, localTable.getPreferredSize().height);
+			globalTable.setBounds(globalHeader.getX(), tableY, compWidth, globalTable.getPreferredSize().height);
+		}
+		
+		// Otherwise, position them vertically.
+		else {
+			// Place the header labels. These are given their preferred
+			// height. Note that this means a very small panel may cut off
+			// some of the components. First, get the preferred height of
+			// the label with the larger preferred height. These should be
+			// the same thing, but just in case...
+			int labelHeight = localHeader.getPreferredSize().height;
+			if(labelHeight < globalHeader.getPreferredSize().height) {
+				labelHeight = globalHeader.getPreferredSize().height;
+			}
+			
+			// The local components go first, taking up the entire upper
+			// width of the panel.
+			localHeader.setBounds(0, 0, getWidth(), labelHeight);
+			localTable.setBounds(0, ComponentUtils.getNextY(localHeader, ComponentUtils.vinternal),
+					getWidth(), localTable.getPreferredSize().height);
+			
+			// The global components go immediately below.
+			globalHeader.setBounds(0, ComponentUtils.getNextY(localTable, ComponentUtils.vinternal),
+					getWidth(), labelHeight);
+			globalTable.setBounds(0, ComponentUtils.getNextY(globalHeader, ComponentUtils.vinternal),
+					getWidth(), globalTable.getPreferredSize().height);
+		}
 	}
 }

Modified: java/trunk/users/src/main/java/org/hps/users/kmccarty/triggerdiagnostics/ui/EfficiencyTablePanel.java
 =============================================================================
--- java/trunk/users/src/main/java/org/hps/users/kmccarty/triggerdiagnostics/ui/EfficiencyTablePanel.java	(original)
+++ java/trunk/users/src/main/java/org/hps/users/kmccarty/triggerdiagnostics/ui/EfficiencyTablePanel.java	Thu Mar  5 10:26:10 2015
@@ -17,7 +17,13 @@
 	/**
 	 * Instantiates a new <code>EfficiencyTablePanel</code>.
 	 */
-	public EfficiencyTablePanel() { super(); }
+	public EfficiencyTablePanel() {
+		// Instantiate the superclass.
+		super();
+		
+		// Set the orientation to vertical.
+		setOrientation(ORIENTATION_VERTICAL);
+	}
 	
 	@Override
 	public void updatePanel(DiagSnapshot snapshot) {

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use