annotate src/org/dancres/blitz/tools/dash/graph/Chart.java @ 6:48228766ed4c

when expecting floating point math, do floating point math
author dbrosius@mebigfatguy.com
date Thu, 14 May 2009 12:15:48 -0400
parents 3dc0c5604566
children 77db38eb3042
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
1 package org.dancres.blitz.tools.dash.graph;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
2
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
3 import org.dancres.blitz.tools.dash.ColorScheme;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
4
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
5 import java.lang.*;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
6 import java.awt.*;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
7 import java.awt.event.*;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
8 import java.text.*;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
9 import javax.swing.*;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
10
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
11 public class Chart extends JPanel
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
12 implements ChartItemEnabler
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
13 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
14
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
15 private class Data
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
16 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
17 double points[];
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
18 String label;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
19 boolean isVisible=true;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
20 double [] pointFactor;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
21 String [] tags;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
22 int [] date;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
23
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
24 public int getSize() { return points.length;}
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
25 public double getPoint(int p) { return points[p];}
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
26 public double getFactor(int f) { return pointFactor[f];}
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
27 public String getTag(int f) { return tags[f];}
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
28 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
29 private static final Color [] chartColor={ColorScheme.READ,
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
30 ColorScheme.WRITE,
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
31 ColorScheme.TAKE};
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
32
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
33 //constraints
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
34 private static final int MAX_DATA_SETS=chartColor.length;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
35
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
36 private int dsCounter=0;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
37 private Data [] dataSet= new Data[MAX_DATA_SETS];
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
38 private int labelEvery=1;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
39 //
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
40 //identifier mappings
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
41 private static final int SOLID=0;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
42 private static final int OUTLINE=1;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
43 private static NumberFormat formatter = NumberFormat.getInstance();
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
44
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
45 private IdDrawer [] idDrawer= new IdDrawer[MAX_DATA_SETS];
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
46
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
47 private int maxSize=0;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
48 private double maxValue=0.0;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
49 private double minValue=0.0;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
50 private int maxId; //index to largest dataset
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
51 private int startAt=0; //for drawing to endAt
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
52 private int endAt=-1; //reset in zoom
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
53 private int [] xTagPosition;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
54
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
55 private Color axisColor=Color.black;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
56 private Color gridColor=Color.gray;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
57 private int yOffset=25;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
58 private boolean dirtyCache;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
59 private Dimension minSize=new Dimension(200,200);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
60 private Dimension currentSize=null;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
61 private Rectangle chartRect= new Rectangle();
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
62 private Rectangle zoomRect;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
63 private boolean isShown=false; //at least one dataset visiable
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
64 //public methods
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
65 public Chart()
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
66 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
67 idDrawer[0]=new SqDrawer(SOLID);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
68 idDrawer[1]=new XDrawer();
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
69 idDrawer[2]=new RoundRectDrawer(SOLID);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
70
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
71
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
72 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
73 synchronized public void addData(final String name,final double [] data,
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
74 final String [] tags)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
75 throws ChartException
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
76 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
77 addData(name,data,tags,null);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
78 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
79 synchronized public void addData(final String name,final double [] data,
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
80 final String [] tags,final int [] dates)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
81 throws ChartException
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
82 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
83 if(dsCounter==MAX_DATA_SETS)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
84 throw new ChartException("Maximum number of data sets exceeded!");
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
85
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
86 setDataAt(dsCounter++,name,data,tags,dates);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
87 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
88 public void setDataAt(int index,final String name,final double [] data,
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
89 final String [] tags,final int [] dates)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
90 throws ChartException
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
91 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
92 dirtyCache=true; //flag that calcFactors must be called internally
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
93 endAt=-1;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
94
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
95 Data d= new Data();
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
96 d.points=data;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
97 d.label=name;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
98 d.tags=tags;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
99 if(dates!=null)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
100 d.date=dates;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
101 else
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
102 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
103 //set to defaults
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
104 int np=data.length;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
105 d.date= new int[np];
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
106 for(int i=0;i<np;i++)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
107 d.date[i]=i;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
108 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
109 d.pointFactor= new double[ tags.length ];
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
110 dataSet[ index ]=d;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
111 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
112 public void setLabelEvery(int every) {labelEvery=every;}
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
113 public static int getMaxSupportedDataSets() {return MAX_DATA_SETS;}
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
114 public Dimension getMinimumSize()
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
115 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
116 return minSize;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
117 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
118 public Dimension getPreferredSize()
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
119 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
120 if(currentSize==null)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
121 currentSize= getSize();
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
122
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
123 return currentSize;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
124 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
125 public void setSize(Dimension d)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
126 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
127 super.setSize(d);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
128 currentSize=d;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
129 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
130
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
131 public void print(final Graphics g,final int yoffset)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
132 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
133 int ty=yOffset;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
134 yOffset=yoffset;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
135 super.print(g);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
136 yOffset=ty;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
137 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
138 public void enableData(final String name,final boolean yesno)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
139 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
140 for( int i=0;i<dsCounter;i++)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
141 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
142 if(dataSet[i].label.compareTo(name)==0)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
143 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
144 dataSet[i].isVisible=yesno;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
145 dirtyCache=true;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
146 repaint();
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
147 return;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
148 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
149 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
150 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
151 public void paint(Graphics g)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
152 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
153 Dimension dim=getSize();
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
154 g.setColor(Color.white);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
155 g.fillRect(0,0,dim.width,dim.height);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
156
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
157 boolean isPrinting=g instanceof PrintGraphics;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
158
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
159 if(dirtyCache)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
160 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
161 calcFactors();
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
162 dirtyCache=false;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
163 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
164 g.setFont( new Font("Dialog",Font.PLAIN,10) );
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
165
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
166 if(dim.height<50) //to small
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
167 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
168 return;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
169 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
170 int xoff=45;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
171 int yoff=yOffset; //set in print(), default==25
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
172 int wid=dim.width-(2*xoff);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
173 int hi=dim.height-(2*yoff);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
174 int baseY=15;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
175 int legy=baseY; //title pos
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
176 int legx=xoff;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
177
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
178 FontMetrics fm=g.getFontMetrics();
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
179
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
180 isShown=false;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
181 boolean firstchart=true;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
182 int ns=dsCounter;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
183 double prevx=0;//last place vert grid line drawn
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
184 double lastLabelPos=-1000;//make sure first label is always drawn
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
185 //Draw dataset titles, then calc size of graphRect
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
186 for(int i=0;i<ns;i++)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
187 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
188 if(dataSet[i].isVisible)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
189 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
190 g.setColor( chartColor[i] );
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
191
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
192 String dslabel=dataSet[i].label;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
193 int strWidth=fm.stringWidth(dslabel);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
194 if((strWidth+legx)>(wid-5) && firstchart==false) //CR
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
195 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
196 legx=xoff;legy+=15;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
197 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
198 firstchart=false;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
199 //draw identifier
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
200 idDrawer[i].draw(g,legx-2,legy-7);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
201 //draw label
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
202 g.drawString(dslabel,legx+5,legy);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
203
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
204 legx+=strWidth+12;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
205 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
206 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
207 //now calc the drawable area for the chart
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
208 // draw zoomable area
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
209 yoff=legy+15;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
210 hi-=(legy-baseY)+5;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
211
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
212 if(zoomRect!=null)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
213 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
214 g.setColor(Color.lightGray);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
215 g.fillRect(zoomRect.x,yoff,zoomRect.width,hi);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
216 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
217 //border
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
218 g.setColor(axisColor);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
219 g.drawRect(xoff,yoff,wid,hi);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
220 //cache for zooming
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
221 chartRect.setBounds(xoff,yoff,wid,hi);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
222 //draw the points
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
223 for(int i=0;i<ns;i++)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
224 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
225 if(dataSet[i].isVisible)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
226 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
227 g.setColor( chartColor[i] );
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
228 int labelWidth=fm.stringWidth(dataSet[i].getTag(0));
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
229
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
230 isShown=true;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
231 int npoints=dataSet[i].getSize();
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
232 double lastx=0;//=xoff;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
233 double lasty=0;//yoff+hi;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
234 int labelCounter=labelEvery; //make sure first label is drawn
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
235
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
236 for(int j=startAt;j<npoints && j<=endAt;j++)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
237 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
238 double val=dataSet[i].getPoint(j);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
239 double xpos=xoff+(wid*dataSet[i].getFactor(j));
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
240 double yfactor=
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
241 (val-minValue)/(maxValue-minValue);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
242 double ypos=yoff+(hi*(1-yfactor));
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
243
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
244 if(lastx==0 && lasty==0)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
245 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
246 //set to current
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
247 lastx=xpos;lasty=ypos;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
248 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
249 if(xpos>(prevx+25))
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
250 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
251 g.setColor(gridColor);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
252 g.drawLine((int)xpos,(int)yoff,
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
253 (int)xpos,(int)yoff+hi+2);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
254 g.setColor(axisColor);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
255 if(labelCounter%labelEvery==0 &&
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
256 xpos>(lastLabelPos+labelWidth+10))
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
257 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
258 xTagPosition[j]=(int)xpos-5;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
259 g.drawString(dataSet[i].getTag(j),xTagPosition[j],(int)yoff+hi+20);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
260 lastLabelPos=xpos;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
261 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
262 else
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
263 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
264 xTagPosition[j]=-1; //invalid
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
265 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
266 g.setColor(chartColor[i]);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
267 prevx=xpos;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
268 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
269
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
270 g.drawLine((int)lastx,(int)lasty,(int)xpos,
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
271 (int)ypos);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
272 //draw identifier
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
273 //g.drawRect((int)xpos-1,(int)ypos-1,2,2);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
274 idDrawer[i].draw(g,(int)xpos-2,(int)ypos-2);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
275 lastx=xpos;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
276 lasty=ypos;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
277 labelCounter++;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
278 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
279
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
280 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
281
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
282 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
283 if(isShown)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
284 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
285
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
286
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
287 double inc=(maxValue-minValue)/4;//number of labels (could be set by client)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
288 double label=maxValue;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
289 double y=yoff;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
290
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
291 //System.out.println("maxValue="+maxValue+"minValue="+minValue+" inc="+inc);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
292
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
293 String str=null;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
294 String lastStr=null;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
295
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
296 //count number of labels to display
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
297 //added version 1.1
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
298 java.util.ArrayList labels=new java.util.ArrayList();
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
299
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
300 for(int yaxis=0;yaxis<5;yaxis++)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
301 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
302
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
303 str=""+(int)label;//formatter.format(label);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
304 int strLen=str.length();
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
305 for(int i=strLen;i<7;i++){
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
306 str=" "+str;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
307 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
308 if(lastStr==null || lastStr.equals(str)==false){
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
309 labels.add(str);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
310 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
311
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
312 lastStr=str;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
313
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
314 label-=inc;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
315 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
316 int nLabels=labels.size();
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
317
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
318 for(int yaxis=0;yaxis<nLabels;yaxis++)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
319 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
320 g.setColor( axisColor );
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
321 str=labels.get(yaxis).toString();
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
322 g.drawString( str,xoff-45,(int)y+6);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
323 g.setColor( gridColor );
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
324 if(yaxis<nLabels-1){
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
325 g.drawLine(xoff-3,(int)y,xoff+wid,(int)y);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
326 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
327
6
48228766ed4c when expecting floating point math, do floating point math
dbrosius@mebigfatguy.com
parents: 0
diff changeset
328 y+=(hi/(nLabels-1.0));
0
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
329
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
330 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
331
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
332 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
333 else
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
334 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
335 g.drawString("no data",legx,legy);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
336 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
337 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
338
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
339 //Private impl
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
340 synchronized private void calcFactors()
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
341 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
342 int tsize=0;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
343 double maxdate=0;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
344 double mindate=Double.MAX_VALUE;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
345 //reset MaxValue
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
346 maxValue=0.0;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
347 maxSize=0;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
348 minValue=Double.MAX_VALUE;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
349 int endpos;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
350 int startpos;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
351 //find the largest dataset, and max dates
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
352 for(int i=0;i<dsCounter;i++)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
353 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
354 if(dataSet[i].isVisible)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
355 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
356 tsize=dataSet[i].getSize();
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
357 if(tsize>maxSize)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
358 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
359 maxSize=tsize;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
360 maxId=i;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
361 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
362 endpos= tsize-1;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
363 if(endAt!=-1 && endAt<tsize)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
364 endpos=endAt;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
365
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
366 startpos=startAt;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
367 if(startpos>=tsize)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
368 startpos=endpos;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
369
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
370 int md=dataSet[ i ].date[ endpos ];
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
371 int mind=dataSet[ i ].date[ startpos ];
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
372 maxdate=md>maxdate?md:maxdate;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
373 mindate=mind<mindate?mind:mindate;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
374 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
375 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
376 if(endAt==-1)//first time
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
377 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
378 endAt=maxSize;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
379 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
380 //allocate xTagPos here - NOT in paint()
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
381 xTagPosition= new int[maxSize];
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
382 //calculate the factors
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
383 for( int i=0;i<dsCounter;i++)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
384 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
385 if(dataSet[i].isVisible)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
386 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
387 int npoints=dataSet[i].getSize();
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
388 for(int j=startAt;j<npoints && j<=endAt;j++)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
389 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
390 double date=dataSet[i].date[j];
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
391 dataSet[i].pointFactor[j]=
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
392 (date-mindate)/(maxdate-mindate);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
393 double val=dataSet[i].getPoint(j);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
394 maxValue=maxValue>val ? maxValue : val;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
395 minValue=val<minValue?val:minValue;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
396 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
397 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
398 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
399 maxValue=adjustMax(maxValue);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
400 minValue=adjustMin(minValue);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
401
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
402 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
403 private double adjustMax(double d)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
404 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
405 double x=d;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
406 if(x>0)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
407 x+=0.05;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
408 else
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
409 x-=0.05;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
410
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
411 return Math.rint(x*10)/10;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
412 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
413 private double adjustMin(double d)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
414 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
415 double x=d;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
416 x-=0.05;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
417 return Math.rint(x*10)/10;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
418 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
419 //private impl classes internal double-dispatch
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
420 private interface IdDrawer
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
421 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
422 public void draw(final Graphics g,final int xpos,final int ypos);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
423 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
424
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
425 private class SqDrawer
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
426 implements IdDrawer
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
427 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
428 private int drawMode;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
429
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
430 public SqDrawer(final int mode)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
431 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
432 drawMode=mode;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
433 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
434 public void draw(final Graphics g,final int xpos,final int ypos)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
435 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
436 if(drawMode==SOLID)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
437 g.fillRect(xpos+1,ypos,4,4);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
438 else
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
439 g.drawRect(xpos,ypos,4,4);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
440 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
441 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
442 private class RoundRectDrawer
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
443 implements IdDrawer
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
444 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
445 private int drawMode;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
446
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
447 public RoundRectDrawer(final int mode)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
448 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
449 drawMode=mode;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
450 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
451 public void draw(final Graphics g,final int xpos,final int ypos)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
452 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
453 if(drawMode==SOLID)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
454 g.fillRoundRect(xpos+1,ypos,4,4,4,4);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
455 else
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
456 g.drawRoundRect(xpos+1,ypos,4,4,4,4);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
457 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
458 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
459 private class XDrawer
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
460 implements IdDrawer
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
461 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
462 public XDrawer()
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
463 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
464 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
465 public void draw(final Graphics g,final int xpos,final int ypos)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
466 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
467 int os=2;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
468
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
469 g.drawLine(xpos-2+os,ypos-2+os,xpos+2+os,ypos+2+os);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
470 g.drawLine(xpos+2+os,ypos-2+os,xpos-2+os,ypos+2+os);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
471 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
472 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
473 //zoomer
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
474 private int dragStartXPos;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
475 private int dragStartYPos;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
476 private int lastXPos;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
477 //private int lastYPos;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
478 private boolean isDragging=false;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
479
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
480 private void setZoomEndPos(int xend)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
481 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
482 Dimension d=getSize();
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
483 int s=dragStartXPos;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
484 int e=xend;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
485 if(s>e) //right to lseft highlight
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
486 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
487 s=xend;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
488 e=dragStartXPos;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
489 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
490 int oldstart=startAt;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
491 int oldend=endAt;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
492 calcNewStartAndEnd(s,e);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
493 if(startAt<endAt)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
494 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
495 calcFactors(); //recalculate the factors
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
496 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
497 else
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
498 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
499 startAt=oldstart;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
500 endAt=oldend;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
501 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
502 //
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
503 /*
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
504 double startFactor=(double)s/(double)d.width;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
505 double endFactor=(double)e/(double)d.width;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
506 int oldstart=startAt;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
507 int oldend=endAt;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
508 startAt+=(int)(endAt*startFactor);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
509 endAt=(int)(endAt*endFactor);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
510 if(startAt<endAt)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
511 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
512 calcFactors(); //recalculate the factors
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
513 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
514 else
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
515 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
516 startAt=oldstart;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
517 endAt=oldend;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
518 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
519 */
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
520 repaint();
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
521 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
522 //calculate startAt, endAt based xTagPositions[]
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
523 private void calcNewStartAndEnd(int xStart,int xEnd)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
524 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
525 //TEST
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
526 //System.out.println("xStart="+xStart+" End="+xEnd);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
527
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
528 int lowerBound=0;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
529 int upperBound=0;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
530 int xLower=0;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
531 int xHigher=0;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
532 int lowestXBound=Integer.MAX_VALUE;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
533 int highestXBound=Integer.MAX_VALUE;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
534
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
535 int size=xTagPosition.length;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
536 for(int i=0;i<size;i++)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
537 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
538 if(xTagPosition[i]!=-1)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
539 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
540
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
541 xLower=xStart-xTagPosition[i];
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
542 xLower=Math.abs(xLower);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
543 if(xLower<lowestXBound)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
544 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
545 lowestXBound=xLower;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
546 lowerBound=i;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
547 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
548 xHigher=xEnd-xTagPosition[i];
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
549 xHigher=Math.abs(xHigher);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
550 if(xHigher<highestXBound)
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
551 {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
552 highestXBound=xHigher;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
553 upperBound=i;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
554 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
555 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
556 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
557 startAt=lowerBound;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
558 endAt=upperBound;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
559
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
560 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
561
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
562 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
563