View Javadoc

1   /*
2    * Copyright (c) 2006 Stiftung Deutsches Elektronen-Synchroton,
3    * Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY.
4    *
5    * THIS SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "../AS IS" BASIS.
6    * WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
7    * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR PARTICULAR PURPOSE AND
8    * NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
9    * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
10   * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
11   * THE USE OR OTHER DEALINGS IN THE SOFTWARE. SHOULD THE SOFTWARE PROVE DEFECTIVE
12   * IN ANY RESPECT, THE USER ASSUMES THE COST OF ANY NECESSARY SERVICING, REPAIR OR
13   * CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
14   * NO USE OF ANY SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
15   * DESY HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
16   * OR MODIFICATIONS.
17   * THE FULL LICENSE SPECIFYING FOR THE SOFTWARE THE REDISTRIBUTION, MODIFICATION,
18   * USAGE AND OTHER RIGHTS AND OBLIGATIONS IS INCLUDED WITH THE DISTRIBUTION OF THIS
19   * PROJECT IN THE FILE LICENSE.HTML. IF THE LICENSE IS NOT INCLUDED YOU MAY FIND A COPY
20   * AT HTTP://WWW.DESY.DE/LEGAL/LICENSE.HTM
21   */
22  
23  package de.desy.acop.chart;
24  import java.awt.Rectangle;
25  
26  public class AcopFrame
27  {
28  	protected java.awt.Color frameForeColor;
29  	protected java.awt.Font frameFont;
30    protected boolean leftTimeLabel;   // it is valid only for x
31    protected boolean absTimeDisplay;
32  	protected int histogramPosition;
33    protected Rectangle histRect;    // pixel width and height
34  	protected boolean drawFlag;
35  	
36  	protected int ZoomExtent;
37    protected Rectangle zoomIcon;
38  	
39  	protected int xleft, xright, dxwidth, absxleft;
40  
41    public AcopFrame()
42  	{
43        histRect = new Rectangle();
44        zoomIcon = new Rectangle();
45        ZoomExtent = 36;
46  		//{{INIT_CONTROLS
47  		//}}
48  	}
49  	
50  	//{{DECLARE_CONTROLS
51    protected void getOxleftright(AcopHisto pHisto, AcopScale pScale)
52    { int Rest, Wpixel, Offset;
53      double xtemp;
54        
55      if ( pHisto.dismode == AcopConst.mode_histogram_rastoring )
56      {
57        dxwidth = Math.min( histRect.width, (int)(pScale.max-pScale.min) );
58        if (dxwidth < 2) dxwidth = pHisto.npoints > 2 ? pHisto.npoints - 1 : 1;
59        if ( histRect.width >= dxwidth )
60        {
61          Wpixel = histRect.width / dxwidth;        // space between two indices
62      	  Offset = histRect.width % Wpixel;		    // fractions to get rid of
63      	  Rest = ((histRect.width-Offset) % dxwidth);// rest to compensate histogram
64      	  if ( histogramPosition == 0 )	    		// left adjusted
65          {
66        		xleft = 0;
67  	   	    xright = histRect.width - Rest - Offset;
68          }
69          else if ( histogramPosition == 2 )  // right adjusted
70          {
71        		xleft = Rest + Offset;
72  		      xright = histRect.width;
73  		    }
74    		  else									// centered
75  	      {
76            xleft = Rest/2;
77            xright = histRect.width - (Rest - Rest/2) - Offset;
78      	  }
79      	}
80      }
81      else
82      {
83        xleft  = 0;
84      	xright = histRect.width;
85      }
86      dxwidth = xright - xleft;
87      absxleft = xleft + histRect.x;
88    }
89  	//}}
90  }
91