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  May 2015

HPS-SVN May 2015

Subject:

r2885 - in /java/trunk/monitoring-util/src/main/java/org/hps/monitoring/trigger: ShifterTrigPanel.java ShifterTrigWindow.java

From:

[log in to unmask]

Reply-To:

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

Date:

Sun, 3 May 2015 05:52:22 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (215 lines)

Author: [log in to unmask]
Date: Sat May  2 22:52:14 2015
New Revision: 2885

Log:
Added in-progress novice trigger diagnostics panels. Note that these are very much still under construction and should not be used for anything.

Added:
    java/trunk/monitoring-util/src/main/java/org/hps/monitoring/trigger/ShifterTrigPanel.java
    java/trunk/monitoring-util/src/main/java/org/hps/monitoring/trigger/ShifterTrigWindow.java

Added: java/trunk/monitoring-util/src/main/java/org/hps/monitoring/trigger/ShifterTrigPanel.java
 =============================================================================
--- java/trunk/monitoring-util/src/main/java/org/hps/monitoring/trigger/ShifterTrigPanel.java	(added)
+++ java/trunk/monitoring-util/src/main/java/org/hps/monitoring/trigger/ShifterTrigPanel.java	Sat May  2 22:52:14 2015
@@ -0,0 +1,177 @@
+package org.hps.monitoring.trigger;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Font;
+
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.SpringLayout;
+
+import org.hps.analysis.trigger.data.DiagnosticSnapshot;
+
+public class ShifterTrigPanel extends JPanel {
+	private static final Color BG_WARNING = new Color(255, 235, 20);
+	private static final Color BG_CRITICAL = new Color(230, 0, 0);
+	private static final Color FONT_WARNING = new Color(255, 157, 0);
+	private static final Color FONT_CRITICAL = new Color(117, 0, 0);
+	private static final long serialVersionUID = 1L;
+	
+	private JLabel panelTitle;
+	private JLabel[] fieldTitle;
+	private JLabel[] fieldValue;
+	
+	public ShifterTrigPanel(String name) {
+		// Instantiate a layout for the fields.
+		SpringLayout layout = new SpringLayout();
+		setLayout(layout);
+		
+		// Instantiate the header title.
+		panelTitle = new JLabel(name);
+		panelTitle.setVerticalAlignment(JLabel.CENTER);
+		panelTitle.setHorizontalAlignment(JLabel.CENTER);
+		add(panelTitle);
+		
+		// Instantiate the field title labels.
+		String[] titleName = { "Cluster Efficiency", "Singles 0 Logic Efficiency",
+				"Singles 0 Trigger Efficiency", "Singles 1 Logic Efficiency",
+				"Singles 1 Trigger Efficiency", "Pair 0 Logic Efficiency",
+				"Pair 0 Trigger Efficiency", "Pair 1 Logic Efficiency", "Pair 1 Trigger Efficiency" };
+		fieldTitle = new JLabel[titleName.length];
+		for(int index = 0; index < titleName.length; index++) {
+			fieldTitle[index] = new JLabel(titleName[index]);
+			fieldTitle[index].setVerticalAlignment(JLabel.CENTER);
+			fieldTitle[index].setHorizontalAlignment(JLabel.RIGHT);
+			fieldTitle[index].setOpaque(true);
+			add(fieldTitle[index]);
+		}
+		
+		// Instantiate the field value labels.
+		fieldValue = new JLabel[titleName.length];
+		for(int index = 0; index < titleName.length; index++) {
+			fieldValue[index] = new JLabel("");
+			fieldValue[index].setVerticalAlignment(JLabel.CENTER);
+			fieldValue[index].setHorizontalAlignment(JLabel.LEFT);
+			fieldValue[index].setOpaque(true);
+			add(fieldValue[index]);
+		}
+		
+		// Get the longest title.
+		int maxWidth = -1;
+		int maxIndex = -1;
+		for(int index = 0; index < titleName.length; index++) {
+			int width = fieldTitle[index].getFontMetrics(fieldTitle[index].getFont()).stringWidth(titleName[index]);
+			if(width > maxWidth) {
+				maxWidth = width;
+				maxIndex = index;
+			}
+		}
+		
+		// Define border edge and spacing variables.
+		String EAST = SpringLayout.EAST;
+		String WEST = SpringLayout.WEST;
+		String NORTH = SpringLayout.NORTH;
+		String SOUTH = SpringLayout.SOUTH;
+		int hinternal =  5;
+		int vinternal = 10;
+		int hexternal =  5;
+		int vexternal =  5;
+		
+		// Position the panel header.
+		layout.putConstraint(EAST,  panelTitle, hexternal, EAST,  this);
+		layout.putConstraint(WEST,  panelTitle, hexternal, WEST,  this);
+		layout.putConstraint(NORTH, panelTitle, vexternal, NORTH, this);
+		
+		// Position the field entries.
+		Component lastComp = panelTitle;
+		for(int index = 0; index < titleName.length; index++) {
+			// For all field titles except the largest, lock the right
+			// edge of the title to match the position of the largest
+			// title's right edge. The largest title is allowed to size
+			// itself to its preferred width.
+			if(index == maxIndex) {
+				layout.putConstraint(NORTH, fieldTitle[index], vinternal, SOUTH, lastComp);
+				layout.putConstraint(WEST,  fieldTitle[index], hexternal, WEST,  this);
+			} else {
+				layout.putConstraint(NORTH, fieldTitle[index], vinternal, SOUTH, lastComp);
+				layout.putConstraint(WEST,  fieldTitle[index], hexternal, WEST,  this);
+				layout.putConstraint(EAST,  fieldTitle[index],         0, EAST,  fieldTitle[maxIndex]);
+			}
+			
+			// Position the field value label to the right of the field
+			// title label. It should use up the remainder of the width
+			// allowed by the component.
+			layout.putConstraint(WEST,  fieldValue[index], hinternal, EAST,  fieldTitle[index]);
+			layout.putConstraint(EAST,  fieldValue[index], hexternal, EAST,  this);
+			layout.putConstraint(NORTH, fieldValue[index], vinternal, SOUTH, lastComp);
+			
+			// Update the "last component" to the current field title
+			// label.
+			lastComp = fieldTitle[index];
+		}
+		
+		// Update the fonts.
+		setFont(getFont());
+	}
+	
+	@Override
+	public void setBackground(Color bg) {
+		// Set the superclass background.
+		super.setBackground(bg);
+		
+		// Set the component backgrounds.
+		if(panelTitle != null) {
+			panelTitle.setBackground(bg);
+			for(int index = 0; index < fieldTitle.length; index++) {
+				fieldTitle[index].setBackground(bg);
+				
+				// If the field value label has a special alert color,
+				// then do not overwrite it.
+				if(!fieldValue[index].getBackground().equals(BG_WARNING)
+						&& !fieldValue[index].getBackground().equals(BG_CRITICAL)) {
+					fieldValue[index].setBackground(bg);
+				}
+			}
+		}
+	}
+	
+	@Override
+	public void setFont(Font font) {
+		// Set the superclass font.
+		super.setFont(font);
+		
+		// Set the component fonts.
+		if(panelTitle != null) {
+			panelTitle.setFont(font.deriveFont(Font.BOLD, (float) (font.getSize2D() * 1.5)));
+			for(int index = 0; index < fieldTitle.length; index++) {
+				fieldTitle[index].setFont(font.deriveFont(Font.BOLD));
+				fieldValue[index].setFont(font);
+			}
+		}
+	}
+	
+	@Override
+	public void setForeground(Color fg) {
+		// Set the superclass foreground.
+		super.setForeground(fg);
+		
+		// Set the component backgrounds.
+		if(panelTitle != null) {
+			panelTitle.setForeground(fg);
+			for(int index = 0; index < fieldTitle.length; index++) {
+				fieldTitle[index].setForeground(fg);
+				
+				// If the field value label has a special alert color,
+				// then do not overwrite it.
+				if(!fieldValue[index].getForeground().equals(FONT_WARNING)
+						&& !fieldValue[index].getForeground().equals(FONT_CRITICAL)) {
+					fieldValue[index].setBackground(fg);
+				}
+			}
+		}
+	}
+	
+	public void updatePanel(DiagnosticSnapshot snapshot) {
+		
+	}
+}

Added: java/trunk/monitoring-util/src/main/java/org/hps/monitoring/trigger/ShifterTrigWindow.java
 =============================================================================
--- java/trunk/monitoring-util/src/main/java/org/hps/monitoring/trigger/ShifterTrigWindow.java	(added)
+++ java/trunk/monitoring-util/src/main/java/org/hps/monitoring/trigger/ShifterTrigWindow.java	Sat May  2 22:52:14 2015
@@ -0,0 +1,15 @@
+package org.hps.monitoring.trigger;
+
+import java.awt.GridLayout;
+
+import javax.swing.JPanel;
+
+public class ShifterTrigWindow extends JPanel {
+	private static final long serialVersionUID = 1L;
+	
+	public ShifterTrigWindow() {
+		setLayout(new GridLayout(1, 2));
+		add(new ShifterTrigPanel("Instantaneous"));
+		add(new ShifterTrigPanel("Run-Integrated"));
+	}
+}

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