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

HPS-SVN July 2015

Subject:

r3325 - /java/trunk/users/src/main/java/org/hps/users/kmccarty/PlotsFormatter.java

From:

[log in to unmask]

Reply-To:

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

Date:

Sat, 1 Aug 2015 02:42:33 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (143 lines)

Author: [log in to unmask]
Date: Fri Jul 31 19:42:32 2015
New Revision: 3325

Log:
Added missing class PlotsFormatter.

Added:
    java/trunk/users/src/main/java/org/hps/users/kmccarty/PlotsFormatter.java

Added: java/trunk/users/src/main/java/org/hps/users/kmccarty/PlotsFormatter.java
 =============================================================================
--- java/trunk/users/src/main/java/org/hps/users/kmccarty/PlotsFormatter.java	(added)
+++ java/trunk/users/src/main/java/org/hps/users/kmccarty/PlotsFormatter.java	Fri Jul 31 19:42:32 2015
@@ -0,0 +1,127 @@
+package org.hps.users.kmccarty;
+
+import hep.aida.ref.plotter.PlotterRegion;
+import jas.hist.JASHist1DHistogramStyle;
+import jas.hist.JASHist2DHistogramStyle;
+
+import java.awt.Color;
+import java.awt.Font;
+
+public class PlotsFormatter {
+	// Define plot fonts.
+	public static final Font BASIC_FONT = new Font("Calibri", Font.PLAIN, 30);
+	public static final Font AXIS_FONT  = new Font("Calibri", Font.BOLD,  35);
+	public static final Font TITLE_FONT = new Font("Calibri", Font.BOLD,  45);
+	
+	// Defines the color style options for plot data.
+	public static enum ColorStyle {
+		 MS_BLUE(new Color( 79, 129, 189), new Color( 36,  64,  97)), MS_ORANGE(new Color(247, 150,  70), new Color(152,  72,   6)),
+		  MS_RED(new Color(192,  80,  77), new Color( 99,  36,  35)),      GREY(new Color(166, 166, 166), new Color( 89,  89,  89)),
+		MS_GREEN(new Color(155, 187,  89), new Color( 79,  98,  40)),   CRIMSON(new Color(161,   0,   0), new Color(104,   0,   0)),
+		    RUST(new Color(161,  80,   0), new Color(105,  80,   0)),    YELLOW(new Color(161, 161,   0), new Color(122, 109,   8)),
+		  FOREST(new Color( 65, 102,   0), new Color( 37,  79,   0)),     GREEN(new Color(  7, 132,  70), new Color(  7,  82,  30)),
+		    TEAL(new Color(  0, 130, 130), new Color(  0,  90, 100)),  CERULEAN(new Color(  0,  86, 130), new Color(  0,  28,  83)),
+		    BLUE(new Color(  0,  33, 203), new Color(  0,   0, 137)),    INDIGO(new Color( 68,  10, 127), new Color(  0,   0,  61)),
+		  PURPLE(new Color(106,   0, 106), new Color( 63,   0,  56)),   FUSCHIA(new Color(119,   0,  60), new Color( 60,   0,  60));
+		
+		private final Color fillColor;
+		private final Color lineColor;
+		
+		private ColorStyle(Color fillColor, Color lineColor) {
+			this.fillColor = fillColor;
+			this.lineColor = lineColor;
+		}
+		
+		public Color getFillColor() { return fillColor; }
+		
+		public Color getLineColor() { return lineColor; }
+	};
+	
+	/**
+	 * Sets the plot display formatting for 1D plots.
+	 * @param region - The plotter region to format.
+	 * @param color - The data color settings to use.
+	 */
+	public static final void setDefault1DStyle(PlotterRegion region, ColorStyle[] color) {
+		// Get the names of each plot on in the region.
+		String[] dataNames = region.getAllDataNames();
+		
+		// Check whether this is an overlay plot. Overlay plots contain
+		// more than one data name.
+		boolean overlay = (dataNames.length > 1 ? true : false);
+		
+		// Iterate over each plot in the region.
+		for(int i = 0; i < dataNames.length; i++) {
+			// Set the overlay style if needed.
+			if(overlay) {
+				// Get the fill style for the current data type.
+				JASHist1DHistogramStyle fillStyle = (JASHist1DHistogramStyle) region.getDataForName(dataNames[i]).getStyle();
+				
+				// Set the histogram style to display thick-lined bars
+				// with no fill. The color is set by the "color" argument.
+				fillStyle.setHistogramFill(false);
+				fillStyle.setHistogramBarLineWidth(3);
+				fillStyle.setHistogramBarLineColor(color[i].getFillColor());
+				
+				// Set the legend text style.
+				region.getPlot().getLegend().setFont(new Font("Calibri", Font.PLAIN, 20));
+			}
+			
+			// Otherwise, set the fill style for a single plot.
+			else {
+				// Get the fill style for the current data type.
+				JASHist1DHistogramStyle fillStyle = (JASHist1DHistogramStyle) region.getDataForName(dataNames[i]).getStyle();
+				
+				// Set the histogram style to display thick-lined bars
+				// with a fill color. The colors are defined by the
+				// "color" argument.
+				fillStyle.setHistogramBarLineWidth(3);
+				fillStyle.setHistogramBarColor(color[i].getFillColor());
+				fillStyle.setHistogramBarLineColor(color[i].getLineColor());
+			}
+			
+			// Set the statistics box style.
+			region.getPlot().getStats().setVisible(true);
+			region.getPlot().getStats().setFont(BASIC_FONT);
+			
+			// Set the title font.
+			region.getPlot().getTitleObject().setFont(TITLE_FONT);
+			
+			// Set the axis tick-mark fonts.
+			region.getPlot().getXAxis().setFont(BASIC_FONT);
+			region.getPlot().getYAxis().setFont(BASIC_FONT);
+			region.getPlot().getXAxis().getLabelObject().setFont(AXIS_FONT);
+			region.getPlot().getYAxis().getLabelObject().setFont(AXIS_FONT);
+		}
+	}
+	
+	/**
+	 * Sets the plot display formatting for 1D plots.
+	 * @param region - The plotter region to format.
+	 */
+	public static final void setDefault2DStyle(PlotterRegion region, boolean logarithmic) {
+		// Get the fill style object. 2D plots should never be overlay
+		// plots, so there should only ever be one data name.
+		JASHist2DHistogramStyle fillStyle = (JASHist2DHistogramStyle) region.getDataForName(region.getAllDataNames()[0]).getStyle();
+		
+		// Set the fill style for a two-dimensional plot.
+		if(logarithmic) { fillStyle.setLogZ(true); }
+		fillStyle.setHistStyle(JASHist2DHistogramStyle.STYLE_COLORMAP);
+		fillStyle.setColorMapScheme(JASHist2DHistogramStyle.COLORMAP_RAINBOW);
+		
+		// Make the statistics box invisible.
+		region.getPlot().getStats().setVisible(false);
+		
+		// Set the general plot font (which is also the z-axis font).
+		region.getPlot().setFont(BASIC_FONT);
+		
+		// Set the title font.
+		region.getPlot().getTitleObject().setFont(TITLE_FONT);
+		
+		// Set the axis tick-mark fonts.
+		region.getPlot().getXAxis().setFont(BASIC_FONT);
+		region.getPlot().getYAxis().setFont(BASIC_FONT);
+		region.getPlot().getXAxis().getLabelObject().setFont(AXIS_FONT);
+		region.getPlot().getYAxis().getLabelObject().setFont(AXIS_FONT);
+	}
+}

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