1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package de.desy.acop.chart;
24
25
26 import java.awt.AWTEvent;
27 import java.awt.BasicStroke;
28 import java.awt.Color;
29 import java.awt.Dimension;
30 import java.awt.Font;
31 import java.awt.FontMetrics;
32 import java.awt.Graphics;
33 import java.awt.Graphics2D;
34 import java.awt.Point;
35 import java.awt.Rectangle;
36 import java.awt.event.ActionEvent;
37 import java.awt.event.ComponentEvent;
38 import java.awt.event.MouseEvent;
39 import java.awt.geom.AffineTransform;
40 import java.awt.geom.Rectangle2D;
41 import java.awt.image.BufferedImage;
42 import java.awt.print.PageFormat;
43 import java.awt.print.Printable;
44 import java.awt.print.PrinterException;
45 import java.awt.print.PrinterJob;
46 import java.beans.Beans;
47 import java.io.FileInputStream;
48 import java.io.IOException;
49 import java.io.InputStream;
50 import java.io.Serializable;
51 import java.util.Vector;
52 import javax.swing.AbstractAction;
53 import javax.swing.JPanel;
54 import javax.swing.JScrollPane;
55 import javax.swing.JTextArea;
56 import javax.swing.plaf.basic.BasicGraphicsUtils;
57 import com.cosylab.gui.components.customizer.AbstractCustomizerPanel;
58 import com.cosylab.gui.components.util.PopupManageable;
59 import com.cosylab.gui.components.util.PopupManager;
60 import com.sun.image.codec.jpeg.JPEGCodec;
61 import com.sun.image.codec.jpeg.JPEGImageDecoder;
62 import de.desy.acop.transport.AcopTransport;
63
64
65
66
67
68
69 public class Acop extends JPanel implements Printable,Serializable, PopupManageable
70 {
71
72
73
74 private static final long serialVersionUID = 351823797042270731L;
75 protected AcopHisto[] histo = new AcopHisto[AcopConst.MAX_DISPLAY];
76
77 protected int globalDisplayMode, enableDots, enableBarlineHisto;
78
79 private AbstractCustomizerPanel customizer;
80 private PopupManager popupManager;
81 private boolean popupEnabled;
82 protected boolean frameBorderOn;
83 boolean forceWidth = false;
84 private int n_display;
85 protected int m_lock;
86 protected boolean drawTicks = true;
87 protected boolean repainHisto = false;
88 protected int rescaleFlag = 2;
89 protected int histIndex = -1;
90 private int loadXYindex = 0;
91 private int m_filled = 0;
92 private int m_keep = 0;
93 protected int lastDisp = 0;
94 protected int lastTagHisto = 0;
95 private int m_numberkeep = 0;
96 private int m_keepstart = 0;
97 protected AcopAxis[] axis = new AcopAxis[AcopConst.MAX_AXIS];
98 protected AcopText[] ptext = new AcopText[AcopConst.MAX_TEXT];
99 private int n_text;
100 private int loadTextIndex = 0;
101 protected boolean textFlag = false;
102 protected int rescaleTextFlag = 0;
103 private double[] g_rdata = new double[512];
104 private boolean RandomInitialized = false;
105 private BasicStroke stroke = new BasicStroke(1.0f);
106
107
108 private double xwidth, ywidth;
109 private Rectangle titleRect = new Rectangle();
110
111 protected Rectangle histRoundRect = new Rectangle();
112 private Rectangle xRect = new Rectangle();
113 private Rectangle yRect = new Rectangle();
114 protected Rectangle yAxisRect = new Rectangle();
115 protected Rectangle tagRect = new Rectangle();
116 private Rectangle zoomRect = new Rectangle();
117 private int changeScaleWidth;
118 private int fLeft, fRight, fTop, fBottom;
119 private int fLeftPixel, fRightPixel, fTopPixel, fBottomPixel;
120 private int HistLeft, HistRight, leftPixel, HistRectleftReference;
121 protected boolean errWindowOn = false;
122 protected boolean ScaleEnable = false;
123 protected boolean ReferenceEnable = false;
124
125 protected double[][] bufferedMin = new double[AcopConst.lengthZoom][3];
126 protected double[][] bufferedMax = new double[AcopConst.lengthZoom][3];
127 protected int zoomIndex, zoomLogFlag;
128 protected boolean isZoomed;
129 protected boolean zoomFlag, movie;
130 protected Point moviepoint;
131 protected int saveBestFlag;
132 protected double moviePercent = 0.01;
133 protected int movieLogCnt = 10;
134 protected int xCnt = 0;
135 protected int yCnt = 0;
136
137 protected int time_scale;
138 protected double tick_xmin, tick_xmax;
139 protected int m_histstart = 0;
140 protected double wrapxmin, wrapxmax;
141 private int mouseX, mouseY, mouseLastX, mouseLastY;
142 private Point mStart, mEnd, mousepoint;
143 private double mouseConvert[] = new double[2];
144 private int mouseIndex;
145 protected AcopScale[] sca = new AcopScale[3];
146
147 protected AcopFrame aFrame = new AcopFrame();
148
149
150 private Vector AcopListeners = new Vector();
151 private java.awt.image.BufferedImage ima;
152
153 private String yZoomRatio, xZoomRatio, bufferedZoomRatio;
154 protected int yzero;
155 protected java.awt.Color foreColor, backColor;
156 private boolean captionChanged;
157 private java.awt.Font captionFont;
158 private double lastTextx, lastTexty;
159 private int nBackRegions;
160 private boolean backgroundRegionFixed;
161 private int backkgroundRegionType[] = new int[AcopConst.MAX_BACKGROUND_REGION];
162 private Rectangle2D.Double[] backRegionUserRect = new Rectangle2D.Double[AcopConst.MAX_BACKGROUND_REGION];
163
164 private Rectangle[] backRegionRect = new Rectangle[AcopConst.MAX_BACKGROUND_REGION];
165
166
167 private Color[] backRegionColor = new Color[AcopConst.MAX_BACKGROUND_REGION];
168
169 private BufferedImage[] backRegionImage = new BufferedImage[AcopConst.MAX_BACKGROUND_REGION];
170
171 protected Color pTagColorArray[];
172 protected int nElement;
173 protected Color TagBackColor;
174 private long mousePreviousClickTime, previousButton;
175 private Point rButtonPoint;
176 protected double yReferenceArray[];
177 protected int yRASize, yRAdataSize;
178 protected double yWindowArray[];
179 protected int yWASize, yWAdataSize;
180 protected double e_xmin, e_xmax, e_ymin, e_ymax;
181
182 protected BasicStroke markerStroke;
183 protected int m_marker;
184 protected int saveMarkerWidth;
185 protected double xlabelRotateGrad, xlabelcos, xlabelsin;
186 protected int xlabelQudrant, xlabelAxis;
187 protected int printScreenPosition;
188 private int averagingIndex, averagingLength, NumberAveragingData;
189 private double totalWeight;
190 private double[] averageWeight = new double[AcopConst.N_DEF_DISPLAY];
191 private double[][] averagingBuffer = new double[AcopConst.N_DEF_DISPLAY][];
192 protected BasicStroke cursorMarkerStroke;
193 private Point mMovePoint = new Point();
194 private Point mOffsetMovePoint = new Point();
195 private int cursorStay, cursorMarkerFlag, cursorix, cursoriy, cursorwx, cursorwy;
196 private double cursorXPercent, cursorYPercent;
197 private double cursorXposition, cursorYposition;
198 public int printScreen()
199 {
200 return printScreen(0);
201 }
202 public int printScreen(int position)
203 {
204 PrinterJob printerJob = PrinterJob.getPrinterJob();
205 PageFormat pageFormat = printerJob.defaultPage();
206 printScreenPosition = (position < 0 || position > 2) ? 0 : position;
207 if (printerJob.pageDialog(pageFormat) != pageFormat)
208 {
209 if (printerJob.printDialog())
210 {
211 printerJob.setPrintable(this);
212 try
213 {
214 printerJob.print();
215 }
216 catch (PrinterException e)
217 {
218
219 e.printStackTrace();
220 }
221 }
222 else
223 System.out.println("PrintDialog was cancelled");
224 }
225 return 0;
226 }
227 public int print(Graphics printG, PageFormat pageFormat, int pageIndex)
228 {
229 if (pageIndex == 0)
230 {
231 Graphics2D g = (Graphics2D) printG;
232 double x1, x2, x3, y1, y2, y3, tmp, scale, offsetX, offsetY;
233 x1 = pageFormat.getImageableWidth();
234 x2 = this.getSize().width;
235 x3 = pageFormat.getImageableX();
236 y1 = pageFormat.getImageableHeight();
237 y2 = this.getSize().height;
238 y3 = pageFormat.getImageableY();
239 tmp = x1 / x2;
240 scale = y1 / y2;
241 offsetX = 0;
242 offsetY = 0;
243 if (printScreenPosition != 0)
244 {
245 if (tmp < scale)
246 {
247 offsetY = y1 - y2 * tmp;
248 if (printScreenPosition == 1) offsetY /= 2;
249 }
250 else
251 {
252 offsetX = x1 - x2 * scale;
253 if (printScreenPosition == 1) offsetX /= 2;
254 }
255 }
256 if (tmp < scale) scale = tmp;
257 double xMargin = (pageFormat.getImageableWidth() - this.getSize().width * scale) / 2 + offsetX;
258 double yMargin = (pageFormat.getImageableHeight() - this.getSize().height * scale) / 2 + offsetY;
259 g.translate(pageFormat.getImageableX() + xMargin, pageFormat.getImageableY() + yMargin);
260 g.scale(scale, scale);
261 paint(g);
262 return PAGE_EXISTS;
263 }
264 else
265 return NO_SUCH_PAGE;
266 }
267 public int setBackgroundRegion(Rectangle2D.Double[] colorRegionRect, Color[] regionColor, boolean fixed)
268 {
269 return setBackgroundRegion(colorRegionRect, regionColor, null, null, fixed);
270 }
271 public int setBackgroundRegion(Rectangle2D.Double[] imageRegionRect, String[] imageFilename, boolean fixed)
272 {
273 return setBackgroundRegion(null, null, imageRegionRect, imageFilename, fixed);
274 }
275 public int setBackgroundRegion(Rectangle2D.Double[] colorRegionRect, Color[] regionColor,
276 Rectangle2D.Double[] imageRegionRect, String[] imageFilename, boolean fixed)
277 {
278 int numColorRegion, numImageRegion, numRegion, colorLength, imageLength;
279 if ((colorRegionRect == null && imageRegionRect == null) ||
280 (regionColor == null && imageFilename == null))
281 {
282 nBackRegions = 0;
283 return 0;
284 }
285 numColorRegion = (colorRegionRect != null && regionColor != null) ? colorRegionRect.length : 0;
286 numImageRegion = (imageRegionRect != null && imageFilename != null) ? imageRegionRect.length : 0;
287 if (numColorRegion <= 0 && numImageRegion <= 0)
288 {
289 nBackRegions = 0;
290 return 0;
291 }
292 colorLength = regionColor != null ? regionColor.length : 0;
293 imageLength = imageFilename != null ? imageFilename.length : 0;
294 numRegion = numColorRegion + numImageRegion;
295 if (numRegion > AcopConst.MAX_BACKGROUND_REGION) numRegion = AcopConst.MAX_BACKGROUND_REGION;
296 for (int i = 0; i < numRegion; i++)
297
298 {
299 backRegionUserRect[i] = i < numColorRegion ? colorRegionRect[i] : imageRegionRect[i - numColorRegion];
300 if (backRegionUserRect[i] == null)
301 {
302 backkgroundRegionType[i] = 0;
303 continue;
304 }
305 if (i < numColorRegion)
306 {
307 backRegionColor[i] = i < colorLength ? regionColor[i] : regionColor[i - 1];
308 backkgroundRegionType[i] = 1;
309 }
310 else
311 {
312 backkgroundRegionType[i] = 2;
313 if (i - numColorRegion >= imageLength)
314 backRegionImage[i] = backRegionImage[i - 1];
315 else
316 try
317 {
318 InputStream in = new FileInputStream(imageFilename[i - numColorRegion]);
319 JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(in);
320 backRegionImage[i] = decoder.decodeAsBufferedImage();
321 }
322 catch (IOException e)
323 {
324 e.printStackTrace();
325 throw new Error("Could not load " + backRegionImage[i] + " with JPEGImageDecoder");
326 }
327 }
328 }
329 backgroundRegionFixed = fixed;
330 if (numRegion > 0)
331 {
332 nBackRegions = numRegion;
333 convertBackgroundRegion(true);
334 }
335 return numRegion;
336 }
337 private void convertBackgroundRegion(boolean fourceConvert)
338 {
339 int xpos, xlength, ypos, ylength;
340 if (nBackRegions == 0) return;
341 if (!fourceConvert && backgroundRegionFixed) return;
342 for (int i = 0; i < nBackRegions; i++)
343 {
344 if (backkgroundRegionType[i] == 0) continue;
345 ylength = (int) (aFrame.histRect.height * backRegionUserRect[i].height / sca[1].dispSize);
346 ypos = (int) (aFrame.histRect.y - ylength + aFrame.histRect.height
347 * (1. - (backRegionUserRect[i].y - sca[1].min) / sca[1].dispSize));
348 xpos = (int) (aFrame.histRect.x + aFrame.histRect.width * (backRegionUserRect[i].x - sca[0].min)
349 / sca[0].dispSize);
350 xlength = (int) (aFrame.histRect.width * backRegionUserRect[i].width / sca[0].dispSize);
351 backRegionRect[i] = new Rectangle(xpos, ypos, xlength, ylength);
352 }
353 }
354 public int setDisplayGap(int pixel)
355 {
356 return setDisplayGap(pixel, pixel);
357 }
358 public int setDisplayGap(int xPixel, int yPixel)
359 {
360 return setDisplayGap(xPixel, xPixel, yPixel, yPixel);
361 }
362 public int setDisplayGap(int xLeftPixel, int xRightPixel, int yTopPixel, int yBottomPixel)
363 {
364 if (xLeftPixel < 0 || xLeftPixel >= aFrame.histRect.width / 2) xLeftPixel = 0;
365 if (xRightPixel < 0 || xRightPixel >= aFrame.histRect.width / 2) xRightPixel = 0;
366 if (yTopPixel < 0 || yTopPixel >= aFrame.histRect.height / 2) yTopPixel = 0;
367 if (yBottomPixel < 0 || yBottomPixel >= aFrame.histRect.height / 2) yBottomPixel = 0;
368 fLeftPixel = xLeftPixel;
369 fRightPixel = xRightPixel;
370 fTopPixel = yTopPixel;
371 fBottomPixel = yBottomPixel;
372 scaleFrameDraw();
373 return xLeftPixel;
374 }
375 protected void averagingScaling(double df[], int start, int stop, int index)
376 {
377 int i, j, max;
378 double maximum;
379 if (averagingDepth > 0)
380 {
381 if (averagingLength == 0)
382 NumberAveragingData = histo[index].npoints;
383 else if (++averagingIndex == averagingDepth) averagingIndex = 0;
384 if (averagingLength < averagingDepth)
385 {
386 if (averagingBuffer[averagingIndex] == null || averagingBuffer[averagingIndex].length < NumberAveragingData)
387 averagingBuffer[averagingIndex] = new double[NumberAveragingData];
388 averagingLength++;
389
390 totalWeight = 0;
391 for (i = 0; i < averagingLength; i++)
392 totalWeight += averageWeight[i];
393 }
394 max = histo[index].npoints < NumberAveragingData ? histo[index].npoints : NumberAveragingData;
395 System.arraycopy(df, 0, averagingBuffer[averagingIndex], 0, max);
396 if (averagingLength > 1) for (j = start; j < stop; j++)
397 {
398 if (j >= max) break;
399 maximum = 0;
400 for (i = 0; i < averagingLength; i++)
401 {
402 if (averagingMode == 0)
403 maximum += averagingBuffer[i][j];
404 else
405 maximum += (averagingBuffer[i][j] * averageWeight[i]);
406 }
407 df[j] = maximum / (averagingMode == 0 ? averagingLength : totalWeight);
408 }
409 }
410 if (yWAdataSize > 0 && histo[index].yScaleEnable)
411 {
412 max = histo[index].npoints < yWAdataSize ? histo[index].npoints : yWAdataSize;
413 for (i = start; i < stop && i < max; i++)
414 df[i] *= yWindowArray[i];
415 }
416 if (yRAdataSize > 0 && histo[index].yReferenceEnable)
417 {
418 max = histo[index].npoints < yRAdataSize ? histo[index].npoints : yRAdataSize;
419 for (i = start; i < stop && i < max; i++)
420 df[i] -= yReferenceArray[i];
421 }
422 }
423 public int weightFunction(Object WeightArray)
424 {
425 return weightFunction(WeightArray, 0);
426 }
427 public int weightFunction(Object WeightArray, int ArraySize)
428 {
429 int ndata;
430 ndata = AcopHisto.getArrayLength(WeightArray);
431 if (ndata <= 0) return -1;
432 if (ArraySize > 0 && ArraySize < ndata) ndata = ArraySize;
433 if (yWindowArray == null || yWASize < ndata)
434 {
435 yWindowArray = new double[ndata];
436 yWASize = ndata;
437 }
438 AcopHisto.copyArray(yWindowArray, WeightArray, 0, ndata, ndata, 1);
439 yWAdataSize = ndata;
440 return 0;
441 }
442 public int referenceFunction(Object ReferenceArray)
443 {
444 return referenceFunction(ReferenceArray, 0);
445 }
446 public int referenceFunction(Object ReferenceArray, int ArraySize)
447 {
448 int ndata;
449 ndata = AcopHisto.getArrayLength(ReferenceArray);
450 if (ndata <= 0) return -1;
451 if (ArraySize > 0 && ArraySize < ndata) ndata = ArraySize;
452 if (yReferenceArray == null || yRASize < ndata)
453 {
454 yReferenceArray = new double[ndata];
455 yRASize = ndata;
456 }
457 AcopHisto.copyArray(yReferenceArray, ReferenceArray, 0, ndata, ndata, 1);
458 yRAdataSize = ndata;
459 return 0;
460 }
461 public boolean isErrorWindowOn()
462 {
463 return isErrorWindowOn(-1, -1);
464 }
465 public boolean isErrorWindowOn(int hDisplay)
466 {
467 return isErrorWindowOn(hDisplay, -1);
468 }
469 public boolean isErrorWindowOn(boolean turnON)
470 {
471 return isErrorWindowOn(-1, turnON ? 1 : 0);
472 }
473 public boolean isErrorWindowOn(int hDisplay, boolean turnON)
474 {
475 return isErrorWindowOn(hDisplay, turnON ? 1 : 0);
476 }
477 private boolean isErrorWindowOn(int hDisplay, int value)
478 {
479 boolean arayon;
480 if (hDisplay < -1 || hDisplay >= n_display) return false;
481
482
483 if (value < 0 || value > 1)
484 return (hDisplay == -1 || histo[hDisplay] == null) ? errWindowOn : histo[hDisplay].errWindowEnable;
485 arayon = value != 0 ? true : false;
486 if (hDisplay != -1)
487 {
488 if (histo[hDisplay] == null) return false;
489 histo[hDisplay].errWindowEnable = arayon;
490 return histo[hDisplay].errWindowEnable;
491 }
492 errWindowOn = arayon;
493 for (int i = 0; i < n_display; i++)
494 {
495 if (histo[i] == null) break;
496 histo[i].errWindowEnable = arayon;
497 }
498 return arayon;
499 }
500 public boolean isWeighted(int hDisplay)
501 {
502 return isWeighted(hDisplay, -1);
503 }
504 public boolean isWeighted(int hDisplay, int value)
505 {
506 boolean arayon;
507 if (hDisplay < -1 || hDisplay >= n_display) return false;
508
509
510 if (value < 0 || value > 1)
511 return (hDisplay == -1 || histo[hDisplay] == null) ? ScaleEnable : histo[hDisplay].yScaleEnable;
512 arayon = value != 0 ? true : false;
513 if (hDisplay != -1)
514 {
515 if (histo[hDisplay] == null) return false;
516 histo[hDisplay].yScaleEnable = arayon;
517 return histo[hDisplay].yScaleEnable;
518 }
519 ScaleEnable = arayon;
520 for (int i = 0; i < n_display; i++)
521 {
522 if (histo[hDisplay] == null) break;
523 histo[hDisplay].yScaleEnable = arayon;
524 }
525 return arayon;
526 }
527 public boolean isReferenced(int hDisplay)
528 {
529 return isReferenced(hDisplay, -1);
530 }
531 public boolean isReferenced(int hDisplay, int value)
532 {
533 boolean arayon;
534 if (hDisplay < -1 || hDisplay >= n_display) return false;
535
536
537 if (value < 0 || value > 1)
538
539 return (hDisplay == -1 || histo[hDisplay] == null) ? ReferenceEnable : histo[hDisplay].yReferenceEnable;
540 arayon = value != 0 ? true : false;
541 if (hDisplay != -1)
542 {
543 if (histo[hDisplay] == null) return false;
544 histo[hDisplay].yReferenceEnable = arayon;
545 return histo[hDisplay].yReferenceEnable;
546 }
547 ReferenceEnable = arayon;
548 for (int i = 0; i < n_display; i++)
549 {
550 if (histo[i] == null) break;
551 histo[i].yReferenceEnable = arayon;
552 }
553 return arayon;
554 }
555 public void SetZoom(boolean XMax, boolean XMin, boolean YMax, boolean YMin, boolean SecondaryYMax, boolean SecondaryYMin, double xmx, double xmn,
556 double ymx, double ymn, double ymxSecondary, double ymnSecondary)
557 {
558 int dezoomFlag = 0, i;
559 double[] storemin = new double[3];
560 double[] storemax = new double[3];
561 if (histo[m_histstart] == null || !aFrame.drawFlag) return;
562 if (!XMax) xmx = sca[0].getMax();
563 if (!XMin) xmn = sca[0].getMin();
564 if (!YMax) ymx = sca[1].getMax();
565 if (!YMin) ymn = sca[1].getMin();
566 if (!SecondaryYMax) ymxSecondary = sca[2].getMax();
567 if (!SecondaryYMin) ymnSecondary = sca[2].getMin();
568 if (xmn >= xmx)
569 {
570 xmn = sca[0].usermin;
571 xmx = sca[0].usermax;
572 }
573 if (ymn >= ymx)
574 {
575 ymn = sca[1].usermin;
576 ymx = sca[1].usermax;
577 }
578 if (ymnSecondary >= ymxSecondary)
579 {
580 ymnSecondary = sca[2].usermin;
581 ymxSecondary = sca[2].usermax;
582 }
583 if ((zooming & 0x4) != 0)
584 {
585 dezoomFlag = 0;
586 if (zoomIndex > 0)
587 {
588 for (i = 0; i < 3; i++)
589 {
590 storemin[i] = sca[i].getMin();
591 storemax[i] = sca[i].getMax();
592 }
593 if (Math.abs((xmx - xmn) - (storemax[0] - storemin[0])) < AcopConst.zero_check
594 && Math.abs((ymx - ymn) - (storemax[1] - storemin[1])) < AcopConst.zero_check
595 && Math.abs((ymxSecondary - ymnSecondary) - (storemax[2] - storemin[2])) < AcopConst.zero_check) return;
596 if ((xmx - xmn) > (storemax[0] - storemin[0]) || (ymx - ymn) > (storemax[1] - storemin[1]) || (ymxSecondary - ymnSecondary) > (storemax[2] - storemin[2]))
597 {
598 dezoomFlag = 1;
599 if (zoomIndex == 1)
600 {
601 xmn = sca[0].usermin;
602 xmx = sca[0].usermax;
603 ymn = sca[1].usermin;
604 ymx = sca[1].usermax;
605 ymnSecondary = sca[2].usermin;
606 ymxSecondary = sca[2].usermax;
607 }
608 }
609 }
610 if (dezoomFlag == 0 && zoomIndex < AcopConst.lengthZoom)
611 {
612 for (i = 0; i < 3; i++)
613 {
614 storemin[i] = sca[i].getMin();
615 storemax[i] = sca[i].getMax();
616 }
617 }
618 }
619 sca[0].setDispscale(xmn, xmx);
620 sca[1].setDispscale(ymn, ymx);
621 sca[2].setDispscale(ymnSecondary, ymxSecondary);
622 if (sca[0].isOriginMaxMin() && sca[1].isOriginMaxMin())
623 {
624 isZoomed = false;
625 if ((zooming & 0x4) != 0) zoomIndex = 0;
626 }
627 else
628 {
629 isZoomed = true;
630 if ((zooming & 0x4) != 0)
631 {
632 if (dezoomFlag != 0)
633 {
634 zoomIndex--;
635 for (i = 0; i < 3; i++)
636 {
637 sca[i].setDispscale(bufferedMin[zoomIndex][i], bufferedMax[zoomIndex][i]);
638 if (sca[i].log != 0) sca[i].setDispscale(Math.pow(10.0, sca[i].min), Math.pow(10.0, sca[i].max));
639 }
640 bufferedZoomRatio = "Z" + zoomIndex;
641 }
642 else if (zoomIndex < AcopConst.lengthZoom)
643 {
644 for (i = 0; i < 3; i++)
645 {
646 bufferedMin[zoomIndex][i] = storemin[i];
647 bufferedMax[zoomIndex][i] = storemax[i];
648 if ( zoomIndex > 0 && sca[i].log != 0 )
649 {
650 if ( storemin[i] > 0 ) bufferedMin[zoomIndex][i] = Math.log(storemin[i]) / Math.log(10);
651 if ( storemax[i] > 0 ) bufferedMax[zoomIndex][i] = Math.log(storemax[i]) / Math.log(10);
652 }
653 }
654 zoomIndex++;
655 bufferedZoomRatio = "Z" + zoomIndex;
656 }
657 }
658 }
659 zoomFlag = false;
660 sca[0].scaleToGrid();
661 if (m_marker == 2) setmarkerflag(2);
662
663
664 rescaleFlag = 1;
665 rescaleTextFlag = AcopConst.NEW_ZOOM_WINDOW;
666 prepareDraw();
667 yZoomRatio = "V" + (int) (sca[1].userSize / sca[1].dispSize + 0.5) + ":1";
668 xZoomRatio = "H" + (int) (sca[0].userSize / sca[0].dispSize + 0.5) + ":1";
669 }
670 public void SetZoom(boolean XMax, boolean XMin, boolean YMax, boolean YMin, double xmx, double xmn,
671 double ymx, double ymn)
672 {
673 SetZoom(XMax, XMin, YMax, YMin, false, false, xmx, xmn, ymx, ymn, 0, 0);
674 }
675 public int getScaledCoordinates(Object Coordinates)
676 {
677 int arySize, i;
678
679 if (Coordinates == null) return 0;
680 arySize = AcopHisto.getArrayLength(Coordinates);
681 if (arySize == 0) return 0;
682 if (arySize > 6) arySize = 6;
683 double[] tmpData = new double[arySize];
684 for (i = 0; i < arySize; i++)
685 tmpData[i] = (i % 2 == 0) ? sca[i / 2].getMin() : sca[i / 2].getMax();
686 arySize = AcopHisto.copyArray(tmpData, Coordinates, 0, arySize, arySize, 0);
687 return arySize;
688 }
689 public int getDrawnData(Object Yarray, Object Xarray, int Npoints, int StartIndex, int hDisplay)
690 {
691 if (hDisplay < 0 || hDisplay >= n_display || histo[hDisplay] == null) return -1;
692 return histo[hDisplay].getDrawnData(Yarray, Xarray, Npoints, StartIndex, hDisplay);
693 }
694 public int getDrawnData(Object Yarray, Object Xarray, int hDisplay, double xPosition, double yPosition)
695 {
696 int dataIndex;
697 if (hDisplay < 0 || hDisplay >= n_display || histo[hDisplay] == null) return -1;
698 dataIndex = histo[hDisplay].getHistoIndex(xPosition, yPosition);
699 return histo[hDisplay].getDrawnData(Yarray, Xarray, 1, dataIndex, hDisplay);
700 }
701 private void setlimit()
702 {
703 isZoomed = false;
704 if ((zooming & 0x4) != 0) zoomIndex = 0;
705 for (int i = 0; i < 3; i++)
706 sca[i].setscale();
707 }
708
709 private void scaleframe()
710 {
711 Rectangle r = getBounds();
712 fLeft = frameWidth + frameLeftOffset;
713 fRight = frameWidth + frameRightOffset;
714 fTop = frameWidth + frameTopOffset;
715 fBottom = frameWidth + frameBottomOffset;
716 if (fLeft < 0)
717 fLeft = 0;
718 else if (fLeft >= r.width) fLeft = r.width - 1;
719 if (fRight < 0)
720 fRight = 0;
721 else if ((fRight + fLeft) >= r.width) fRight = r.width - fLeft - 1;
722 if (fTop < 0)
723 fTop = 0;
724 else if (fTop >= r.height) fTop = r.height - 1;
725 if (fBottom < 0)
726 fBottom = 0;
727 else if ((fBottom + fTop) >= r.height) fBottom = r.height - fTop - 1;
728
729
730 titleRect.setBounds(0, 0, r.width, fTop);
731
732
733
734
735 aFrame.histRect.setBounds(fLeft + fLeftPixel, fTop + fTopPixel, r.width - fLeft - fRight - fLeftPixel
736 - fRightPixel, r.height - fTop - fBottom - fTopPixel - fBottomPixel);
737 aFrame.zoomIcon.setBounds(aFrame.histRect.x + aFrame.histRect.width - aFrame.ZoomExtent,
738 aFrame.histRect.y + 1, aFrame.ZoomExtent - 1, aFrame.ZoomExtent - 1);
739
740
741 histRoundRect.setBounds(aFrame.histRect.x - fLeftPixel - 1, aFrame.histRect.y - fTopPixel - 1,
742 aFrame.histRect.width + fLeftPixel + fRightPixel + 2, aFrame.histRect.height + fTopPixel
743 + fBottomPixel + 2);
744
745 xRect.setBounds(0, r.height - fBottom, r.width, fBottom);
746 setTickRectangle(0);
747
748 yRect.setBounds(0, 0, fLeft, r.height);
749
750 yAxisRect.setBounds(r.width - fRight, 0, fRight, r.height);
751 setTickRectangle(1);
752 tagRect.setBounds(histRoundRect);
753 HistRectleftReference = aFrame.histRect.x + leftPixel;
754 listTextBox
755 .setBounds(aFrame.histRect.x, aFrame.histRect.y, aFrame.histRect.width, aFrame.histRect.height);
756 }
757
758 private void setTickRectangle(int i)
759 {
760 Rectangle tmpRect;
761 if (sca[i].leftBottom)
762 {
763 sca[i].ticksRect = i == 0 ? xRect : yRect;
764 tmpRect = i == 0 ? titleRect : yAxisRect;
765 }
766 else
767 {
768 sca[i].ticksRect = i == 0 ? titleRect : yAxisRect;
769 tmpRect = i == 0 ? xRect : yRect;
770 }
771 if (i == 1)
772 {
773 sca[2].ticksRect = tmpRect;
774 sca[2].labelRect = sca[i].leftBottom != sca[i].leftBottLabel ? sca[i].ticksRect : tmpRect;
775 sca[2].leftBottom = sca[i].leftBottom ? false : true;
776 sca[2].leftBottLabel = sca[i].leftBottLabel ? false : true;
777 }
778 sca[i].labelRect = sca[i].leftBottom == sca[i].leftBottLabel ? sca[i].ticksRect : tmpRect;
779 }
780 private boolean drawOneHist(int num)
781 {
782 Graphics2D a = (Graphics2D) getGraphics();
783 if (a == null) return false;
784 a.setClip(histRoundRect.x, histRoundRect.y, histRoundRect.width, histRoundRect.height);
785 a.translate(aFrame.histRect.x, aFrame.histRect.y);
786 histo[num].drawhist(a);
787 a.translate(-aFrame.histRect.x, -aFrame.histRect.y);
788 a.dispose();
789 return true;
790 }
791 protected void prepareDraw()
792 {
793 double xtemp, ytemp;
794 int i, j, start, ende, ret;
795 if (randomData == true && sca[0].usermax > sca[0].usermin && sca[1].usermax > sca[1].usermin)
796 {
797 if (RandomInitialized == false)
798 {
799 for (i = 0; i < 512; i++)
800 g_rdata[i] = Math.sin(i * 6.2832 / 512.);
801 RandomInitialized = true;
802 }
803 xtemp = sca[0].userSize + 1;
804 if (xtemp < 1.0) xtemp = 1.0;
805 j = (int) xtemp;
806 double[] ppvdata = new double[j];
807 for (i = 0; i < j; i++)
808 ppvdata[i] = sca[1].usermin + (1 + g_rdata[j >= 512 ? i % 512 : (int) (i * 512 / xtemp) % 512])
809 * sca[1].userSize / 2;
810 if (histo[0] == null)
811 {
812 histo[0] = new AcopHisto(this, 0);
813 }
814 if (histo[0].setHisto(ppvdata, null, null, null, 0, 0, foreColor) == 0)
815 {
816 if (wrapAround) histo[0].getMaxWindow();
817 aFrame.drawFlag = true;
818 histo[0].displayON = 1;
819 histo[0].dismode = globalDisplayMode;
820 histo[0].disDots = enableDots;
821 histo[0].disBarHisto = enableBarlineHisto;
822 histo[0].xext = XExtent;
823 histo[0].yext = YExtent;
824 histo[0].colorfilled = colorFilled;
825 histo[0].barlineColorFilled = barlineColorFilled;
826 loadXYindex = 0;
827 lastDisp = 0;
828 }
829 }
830 if (rescaleFlag == 2)
831 {
832 setlimit();
833 sca[0].scaleToGrid();
834 }
835 if (rescaleFlag > 0)
836 {
837 for (i = 0; i < 3; i++)
838 sca[i].xyscale(rescaleFlag == 2 ? true : false);
839
840 }
841
842 if (rescaleFlag > 0 || drawTicks) convertBackgroundRegion(false);
843
844 if (histIndex < 0 || histIndex >= n_display)
845 {
846 start = 0;
847 ende = n_display;
848 }
849 else
850 {
851 start = histIndex;
852 ende = histIndex + 1;
853 }
854 if (aFrame.drawFlag) for (i = start; i < ende; i++)
855 {
856 if (histo[i] == null) break;
857 if (histo[i].displayON == 0 && i != m_histstart) continue;
858
859
860 if (i == m_histstart) aFrame.getOxleftright(histo[i], sca[0]);
861
862 if (wrapAround && rescaleFlag != 0 && sca[0].log == 0) histo[i].setwrapindex();
863 histo[i].setExtent();
864 if (i == m_histstart)
865 {
866 if (histo[i].dismode == AcopConst.mode_textbox)
867 {
868
869 String allStmp = "";
870 textArea.setText(allStmp);
871 }
872 else
873 listTextBox.setVisible(false);
874 }
875
876 histo[i].mapScreen(-1);
877 }
878 if (rescaleTextFlag > 0) for (i = 0; i < n_text; i++)
879 {
880 if (ptext[i] == null) break;
881 ptext[i].rescaleText(rescaleTextFlag);
882 }
883
884
885
886
887
888
889
890
891
892 if ((rescaleFlag > 0 || drawTicks) && cursorStay > 0)
893 {
894 mMovePoint.x = sca[0].getScreenPosition(cursorXposition);
895 mMovePoint.y = sca[1].getScreenPosition(cursorYposition);
896 }
897 if (sca[1].log != 0)
898 yzero = aFrame.histRect.height;
899 else if (sca[1].max >= 0 && sca[1].min <= 0)
900 yzero = (int) (aFrame.histRect.height * (1 + sca[1].min / sca[1].dispSize));
901 else
902 yzero = (int) ((sca[1].max > 0 && sca[1].min > 0) ? aFrame.histRect.height : 0);
903 if (repainHisto == true && drawTicks == false && rescaleFlag == 0 && rescaleTextFlag == 0
904 && start + 1 == ende)
905 {
906 if (drawOneHist(start) == false) repaintHisto();
907 }
908 else if (rescaleFlag > 0 || drawTicks)
909 repaint();
910
911
912 else
913 repaintHisto();
914 rescaleTextFlag = 0;
915 rescaleFlag = 0;
916 drawTicks = false;
917 histIndex = -1;
918 repainHisto = false;
919 }
920 private void setGlobalDisplayMode()
921 {
922 globalDisplayMode = displayMode;
923 if ( displayMode > AcopConst.mode_textbox )
924 {
925 if ( displayMode == AcopConst.mode_polyline_dots ) globalDisplayMode = AcopConst.mode_polyline;
926 if ( displayMode == AcopConst.mode_barline_dots ) globalDisplayMode = AcopConst.mode_barline;
927 if ( displayMode == AcopConst.mode_histogram_dots ) globalDisplayMode = AcopConst.mode_histogram;
928 if ( displayMode == AcopConst.mode_histogram_rastoring_dots ) globalDisplayMode = AcopConst.mode_histogram_rastoring;
929 if ( displayMode != AcopConst.mode_barline_histo ) enableDots = 1;
930 else enableDots = 0;
931 if ( displayMode == AcopConst.mode_barline_histo || displayMode == AcopConst.mode_barline_histo_dots )
932 {
933 globalDisplayMode = AcopConst.mode_barline;
934 enableBarlineHisto = 1;
935 }
936 else enableBarlineHisto = 0;
937 }
938 else
939 {
940 enableDots = 0;
941 enableBarlineHisto = 0;
942 }
943
944 }
945
946 public Acop()
947 {
948
949
950 setLayout(null);
951 setSize(502, 350);
952 setPreferredSize(new Dimension(502, 350));
953 setMinimumSize(new Dimension(100, 100));
954 setPopupEnabled(true);
955 captionPosition = 1;
956 captionChanged = true;
957 keepColor = Color.gray;
958 keepWidth = 1;
959 keepStyle = AcopConst.PS_SOLID;
960 m_tagColor = Color.cyan;
961 m_tagging = false;
962 pTagColorArray = null;
963 nElement = 0;
964 m_marker = 0;
965 saveMarkerWidth = 0;
966 m_markerColor = Color.black;
967 m_markerMode = 0;
968 m_markerStyle = AcopConst.PS_SOLID;
969 m_markerWidth = 1;
970 m_markerXExtent = -1;
971 m_markerYExtent = -1;
972 m_cursorMarkerColor = Color.black;
973 rev_cursorMarkerColor = Color.white;
974 m_cursorMarkerMode = 0;
975 m_cursorMarkerStyle = AcopConst.PS_SOLID;
976 m_cursorMarkerWidth = 1;
977 cursorMarkerStroke = AcopConst.createStroke(m_cursorMarkerWidth, m_cursorMarkerStyle);
978 m_cursorMarkerXExtent = -1;
979 m_cursorMarkerYExtent = -1;
980 mMovePoint.setLocation(-1, -1);
981 mOffsetMovePoint.setLocation(-1, -1);
982 cursorStay = 0;
983 cursorXPercent = -1;
984 cursorYPercent = -1;
985 cursorMarkerFlag = 0;
986 cursorix = 0;
987 cursoriy = 0;
988 cursorwx = 0;
989 cursorwy = 0;
990 m_errorColor = Color.red;
991 colorFilled = true;
992 averagingMode = 0;
993 averagingDepth = 0;
994 averagingIndex = 0;
995 averagingLength = 0;
996 NumberAveragingData = 0;
997 for (int i = 0; i < AcopConst.N_DEF_DISPLAY; i++)
998 averageWeight[i] = Math.exp((double) i);
999 FFT = 0;
1000 printScreenPosition = 0;
1001 for (int i = 0; i < 3; i++)
1002 {
1003 if (i < 2) axis[i] = new AcopAxis(this, i);
1004 sca[i] = new AcopScale(this, i == 0 ? true : false);
1005
1006 sca[i].ticks = -1;
1007 sca[i].fineTicks = 1;
1008 sca[i].grid = false;
1009 sca[i].leftBottom = i < 2 ? true : false;
1010 sca[i].bestScale = true;
1011 sca[i].ticktext = true;
1012 sca[i].log = 0;
1013 sca[i].xtime = 0;
1014 sca[i].tickLabelForeColor = Color.gray;
1015 sca[i].leftBottLabel = true;
1016 sca[i].OnFlag = i < 2 ? true : false;
1017 sca[i].setUserscale(i == 0 ? 0 : -100, 100);
1018 }
1019 textArea = new JTextArea();
1020
1021 listTextBox = new JScrollPane(textArea);
1022 this.add(listTextBox);
1023 listTextBox.setVisible(false);
1024 nBackRegions = 0;
1025 changeScaleWidth = 0;
1026 invert = false;
1027 XShift = 0;
1028 XScale = 1;
1029 YShift = 0;
1030 YScale = 1;
1031 leftPixel = 0;
1032 RandomInitialized = false;
1033 randomData = Beans.isDesignTime();
1034 randomText = Beans.isDesignTime();
1035 frameWidth = 30;
1036 frameLeftOffset = 10;
1037 frameRightOffset = 0;
1038 frameTopOffset = 0;
1039 frameBottomOffset = 0;
1040 graphStyle = 0;
1041 aFrame.leftTimeLabel = true;
1042 aFrame.absTimeDisplay = false;
1043 aFrame.histogramPosition = 1;
1044 aFrame.frameForeColor = Color.gray;
1045 aFrame.frameFont = new Font("MonoSpaced", Font.PLAIN, 12);
1046 caption = "test";
1047 displayMode = AcopConst.mode_polyline;
1048 setGlobalDisplayMode();
1049 e_xmin = 0;
1050 e_xmax = 100;
1051 drawWidth = 1;
1052 drawStyle = AcopConst.PS_SOLID;
1053 e_ymin = -100;
1054 e_ymax = 100;
1055
1056 m_lock = 0;
1057 screenDepth = 20;
1058 n_display = screenDepth;
1059 textDepth = 20;
1060 n_text = textDepth;
1061 m_filled = 0;
1062 barlineColorFilled = 0;
1063 wrapxmin = -1.7e+308;
1064 wrapxmax = 1.7e+308;
1065 zoomIndex = 0;
1066 zoomLogFlag = 0;
1067 zooming = 7;
1068 isZoomed = false;
1069 zoomFlag = false;
1070 reuseScreen = false;
1071 reuseText = false;
1072 XExtent = 0;
1073 YExtent = 0;
1074 xlabelRotation = 0;
1075 foreColor = getForeground();
1076 backColor = getBackground();
1077 wrapAround = false;
1078 printTextStickyAttribute = 0;
1079 printTextLocation = 0;
1080 printTextRotation = 0;
1081 LeadingEdgeColor = getForeground();
1082 LeadingEdgeGapSize = 0;
1083 LeadingEdgeMotion = 0;
1084 LeadingEdgeMode = 0;
1085 LeadingEdgeWidth = 1;
1086 LeadingEdgeStyle = AcopConst.PS_SOLID;
1087 LeadingEdgeXExtent = -1;
1088 LeadingEdgeYExtent = -1;
1089 yRASize = yRAdataSize = 0;
1090 yWASize = yWAdataSize = 0;
1091 fLeft = 0;
1092 fRight = 0;
1093 fTop = 0;
1094 fBottom = 0;
1095 fLeftPixel = 0;
1096 fRightPixel = 0;
1097 fTopPixel = 0;
1098 fBottomPixel = 0;
1099 frameBorderOn = true;
1100 if ((zooming & 0x7) != 0) setZoomingWindow(zooming & 0x4);
1101 scaleFrameDraw();
1102 if (Beans.isDesignTime() && randomData == true)
1103 {
1104 prepareDraw();
1105
1106 }
1107
1108 enableEvents(AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.COMPONENT_EVENT_MASK);
1109
1110 }
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138 public int lockCursorMarker(boolean Enable)
1139 {
1140 return lockCursorMarker(Enable, false, 0, false, 0);
1141 }
1142 public int lockCursorMarker(boolean Enable, double Xposition, double Yposition)
1143 {
1144 return lockCursorMarker(Enable, true, Xposition, true, Yposition);
1145 }
1146 public int lockCursorMarker(boolean Enable, boolean xInput, double Xposition, boolean yInput,
1147 double Yposition)
1148 {
1149 int on;
1150 if (m_cursorMarkerMode == 0) return -1;
1151 on = Enable ? 1 : 0;
1152 cursorStay = on;
1153 if (cursorStay > 0)
1154 {
1155 if (xInput)
1156 mMovePoint.x = sca[0].getScreenPosition(Xposition);
1157 else
1158 Xposition = sca[0].getUserPosition(mMovePoint.x);
1159 if (yInput)
1160 mMovePoint.y = sca[1].getScreenPosition(Yposition);
1161 else
1162 Yposition = sca[1].getUserPosition(mMovePoint.y);
1163 cursorXposition = Xposition;
1164 cursorYposition = Yposition;
1165 }
1166 if (aFrame.drawFlag) repaintHisto();
1167 return on;
1168 }
1169 private void drawCursorMarker(Graphics2D g2d, Point point)
1170 { int modeTmp;
1171 Rectangle Cliprect = null;
1172 int initFlag = g2d == null ? 0 : 1;
1173 if (g2d == null)
1174
1175 {
1176 g2d = (Graphics2D) getGraphics();
1177 Cliprect = g2d.getClipBounds();
1178 if (Cliprect != null)
1179 {
1180 if (Cliprect.intersects(histRoundRect) == false) return;
1181 }
1182 }
1183 g2d.setXORMode(rev_cursorMarkerColor);
1184
1185
1186 g2d.setStroke(cursorMarkerStroke);
1187 if (initFlag == 0)
1188
1189 {
1190 g2d.clipRect(histRoundRect.x, histRoundRect.y, histRoundRect.width, histRoundRect.height);
1191
1192 if (cursorMarkerFlag == 2)
1193 {
1194 modeTmp = m_cursorMarkerMode;
1195 m_cursorMarkerMode = 0;
1196 paintImmediately(histRoundRect);
1197 m_cursorMarkerMode = modeTmp;
1198 }
1199 else if (cursorMarkerFlag != 0)
1200 {
1201 if ((m_cursorMarkerMode & 0x2) != 0)
1202 g2d.drawLine(cursorwy, cursorwx - cursoriy, cursorwy, cursorwx + cursoriy);
1203 if ((m_cursorMarkerMode & 0x1) != 0)
1204 g2d.drawLine(cursorwy - cursorix, cursorwx, cursorwy + cursorix, cursorwx);
1205 }
1206 }
1207
1208 cursorwx = point.y;
1209 cursorwy = point.x;
1210 if (initFlag != 0)
1211 {
1212 cursorwx -= aFrame.histRect.y;
1213 cursorwy -= aFrame.histRect.x;
1214 }
1215 if ((m_cursorMarkerMode & 0x1) != 0)
1216 {
1217 if (initFlag != 0)
1218 {
1219 if (cursorXPercent < 0)
1220 {
1221 if (m_cursorMarkerXExtent < 0)
1222 cursorXPercent = 1;
1223 else
1224 cursorXPercent = ((sca[0].log != 0) ? Math.log(m_cursorMarkerXExtent) / Math.log(10)
1225 : m_cursorMarkerXExtent)
1226 / (sca[0].tick_max - sca[0].tick_min) / 2;
1227 }
1228 cursorix = (int) (aFrame.histRect.width * cursorXPercent);
1229 }
1230 g2d.drawLine(cursorwy - cursorix, cursorwx, cursorwy + cursorix, cursorwx);
1231 }
1232 if ((m_cursorMarkerMode & 0x2) != 0)
1233 {
1234 if (initFlag != 0)
1235 {
1236 if (cursorYPercent < 0)
1237 {
1238 if (m_cursorMarkerYExtent < 0)
1239 cursorYPercent = 1;
1240 else
1241 cursorYPercent = ((sca[1].log != 0) ? Math.log(m_cursorMarkerYExtent) / Math.log(10)
1242 : m_cursorMarkerYExtent)
1243 / sca[1].dispSize / 2;
1244 }
1245 cursoriy = (int) (aFrame.histRect.height * cursorYPercent);
1246 }
1247 g2d.drawLine(cursorwy, cursorwx - cursoriy, cursorwy, cursorwx + cursoriy);
1248 }
1249 g2d.setPaintMode();
1250 if (initFlag == 0)
1251 {
1252
1253 g2d.setClip(Cliprect);
1254 g2d.dispose();
1255 }
1256 if (initFlag != 0)
1257 {
1258 cursorwx += aFrame.histRect.y;
1259 cursorwy += aFrame.histRect.x;
1260 }
1261 cursorMarkerFlag = initFlag == 1 ? 2 : 1;
1262 }
1263 private void setZoomingWindow(int bufferedZoomFlag)
1264 {
1265 aFrame.ZoomExtent = bufferedZoomFlag != 0 ? 20 : 36;
1266
1267 aFrame.zoomIcon.setBounds(aFrame.histRect.x + aFrame.histRect.width - aFrame.ZoomExtent,
1268 aFrame.histRect.y + 1, aFrame.ZoomExtent - 1, aFrame.ZoomExtent - 1);
1269 }
1270 public java.lang.String getPrintedText(double[] leftBottom, double[] size, double[] position, int hText)
1271 {
1272 if (hText < 0 || hText >= n_text || ptext[hText] == null) return "Input Error!";
1273 return ptext[hText].getPrintedText(leftBottom, size, position);
1274 }
1275 public boolean isZoomed()
1276 {
1277 return this.isZoomed;
1278 }
1279 public int getHistogramOffsetLeft()
1280 {
1281 return aFrame.xleft;
1282 }
1283 public int getHistogramOffsetRight()
1284 {
1285 return aFrame.histRect.width - aFrame.xright;
1286 }
1287 public double getScaleLeft()
1288 {
1289 return sca[0].getMin();
1290 }
1291 public double getScaleRight()
1292 {
1293 return sca[0].getMax();
1294 }
1295 public double getScaleTop()
1296 {
1297 return sca[1].getMax();
1298 }
1299 public double getScaleBottom()
1300 {
1301 return sca[1].getMin();
1302 }
1303 private int loadAxis(int index, boolean AxisOn, Object PositionArray, int ArraySize, Color[] ColorArray,
1304 int[] StyleArray, int[] WidthArray)
1305 {
1306 int ret;
1307 ret = axis[index].axisON != AxisOn ? 1 : 0;
1308 axis[index].axisON = AxisOn;
1309 if (ArraySize < 1 && ArraySize != -1) return -1;
1310 if (ArraySize != -1)
1311 ret += axis[index].loadData(ArraySize, PositionArray, ColorArray, StyleArray, WidthArray);
1312 if (ret != 0 && aFrame.drawFlag) repaintHisto();
1313 return 0;
1314 }
1315 public int xAxis(boolean AxisOn)
1316 {
1317 return loadAxis(0, AxisOn, null, -1, null, null, null);
1318 }
1319 public int yAxis(boolean AxisOn)
1320 {
1321 return loadAxis(1, AxisOn, null, -1, null, null, null);
1322 }
1323 public int xAxis(boolean AxisOn, Object PositionArray, int ArraySize, Color[] ColorArray, int[] StyleArray,
1324 int[] WidthArray)
1325 {
1326 return loadAxis(0, AxisOn, PositionArray, ArraySize, ColorArray, StyleArray, WidthArray);
1327 }
1328 public int yAxis(boolean AxisOn, Object PositionArray, int ArraySize, Color[] ColorArray, int[] StyleArray,
1329 int[] WidthArray)
1330 {
1331 return loadAxis(1, AxisOn, PositionArray, ArraySize, ColorArray, StyleArray, WidthArray);
1332 }
1333 public int refreshScreen(Object Yarray, int hDisplay, int Npoints, int StartIndex, Object Xarray)
1334 {
1335 if (hDisplay < 0 || hDisplay >= n_display || histo[hDisplay] == null) return -1;
1336 return histo[hDisplay].updateScreen(false, Yarray, Npoints, StartIndex, Xarray);
1337 }
1338 public int refreshScreen(Object Yarray, int hDisplay, Object Xarray)
1339 {
1340 if (hDisplay < 0 || hDisplay >= n_display || histo[hDisplay] == null) return -1;
1341 return histo[hDisplay].updateScreen(false, Yarray, -1, -1, Xarray);
1342 }
1343 public int refreshScreen(Object Yarray, int hDisplay)
1344 {
1345 if (hDisplay < 0 || hDisplay >= n_display || histo[hDisplay] == null) return -1;
1346 return histo[hDisplay].updateScreen(false, Yarray, -1, -1, null);
1347 }
1348 public int appendScreen(Object Yarray, int hDisplay, int Npoints, int StartIndex, Object Xarray)
1349 {
1350 if (hDisplay < 0 || hDisplay >= n_display || histo[hDisplay] == null) return -1;
1351 return histo[hDisplay].updateScreen(true, Yarray, Npoints, StartIndex, Xarray);
1352 }
1353 public int appendScreen(Object Yarray, int hDisplay, Object Xarray)
1354 {
1355 if (hDisplay < 0 || hDisplay >= n_display || histo[hDisplay] == null) return -1;
1356 return histo[hDisplay].updateScreen(true, Yarray, -1, -1, Xarray);
1357 }
1358 public int appendScreen(Object Yarray, int hDisplay)
1359 {
1360 if (hDisplay < 0 || hDisplay >= n_display || histo[hDisplay] == null) return -1;
1361 return histo[hDisplay].updateScreen(true, Yarray, -1, -1, null);
1362 }
1363 public int draw(Object ydata)
1364 {
1365 return draw(ydata, null, null, null, 0, 0);
1366 }
1367
1368 public int draw(Object ydata, Object xdata, boolean bindToSecondaryAxis) {
1369 return draw(ydata, xdata, null, null, 0, 0,bindToSecondaryAxis);
1370 }
1371 public int draw(Object ydata, Object xdata)
1372 {
1373 return draw(ydata, xdata, null, null, 0, 0);
1374 }
1375 public int draw(Object ydata, Object xdata, Object disable)
1376 {
1377 return draw(ydata, xdata, disable, null, 0, 0);
1378 }
1379 public int draw(Object ydata, Object xdata, Object disable, java.lang.String[] xlabel)
1380 {
1381 return draw(ydata, xdata, disable, xlabel, 0, 0);
1382 }
1383 public int draw(Object ydata, Object xdata, Object disable, java.lang.String[] xlabel, int ArraySize,
1384 int MaxNumber) {
1385 return draw(ydata,xdata,disable,xlabel,ArraySize,MaxNumber,false);
1386 }
1387
1388 public int draw(Object ydata, Object xdata, Object disable, java.lang.String[] xlabel, int ArraySize,
1389 int MaxNumber, boolean bindToSecondaryAxis)
1390 {
1391 int i, tmp;
1392 if (m_lock == n_display) return -1;
1393
1394 if (aFrame.drawFlag == true && histo[loadXYindex] != null && histo[loadXYindex].displayON == 1)
1395 {
1396
1397 for (i = loadXYindex + 1, tmp = 0; tmp < n_display; i++, tmp++)
1398 {
1399 if (i == n_display)
1400 {
1401 i = 0;
1402 m_filled = 1;
1403 }
1404 if (histo[i] == null || (histo[i].lockFlag == 0 && histo[i].displayON == 0))
1405 break;
1406 else if (reuseScreen && histo[i].lockFlag == 0) break;
1407 }
1408 if (tmp < n_display)
1409 loadXYindex = i;
1410 else
1411 return -2;
1412 }
1413 if (histo[loadXYindex] == null)
1414 {
1415 histo[loadXYindex] = new AcopHisto(this, loadXYindex);
1416 if (loadXYindex == 0 && aFrame.drawFlag == false && textFlag == true)
1417 rescaleTextFlag = AcopConst.NEW_PRINT_WINDOW;
1418 if (loadXYindex == 0 && textFlag == false)
1419 {
1420 }
1421 }
1422 if (histo[loadXYindex].setHisto(ydata, xdata, disable, xlabel, ArraySize, MaxNumber, foreColor) != 0)
1423 return -3;
1424
1425 if (aFrame.drawFlag == false)
1426 drawTicks = true;
1427 else
1428 drawTicks = false;
1429
1430 if (aFrame.drawFlag == true && histo[loadXYindex].displayON == 0) repainHisto = true;
1431
1432
1433 aFrame.drawFlag = true;
1434 histo[loadXYindex].displayON = 1;
1435 histo[loadXYindex].dismode = globalDisplayMode;
1436 histo[loadXYindex].disDots = enableDots;
1437 histo[loadXYindex].disBarHisto = enableBarlineHisto;
1438 histo[loadXYindex].xext = XExtent;
1439 histo[loadXYindex].yext = YExtent;
1440 histo[loadXYindex].colorfilled = colorFilled;
1441 histo[loadXYindex].barlineColorFilled = barlineColorFilled;
1442 if (m_keep == 0)
1443 {
1444 if (m_filled != 0 && m_lock == 0)
1445 {
1446 m_histstart = loadXYindex + 1;
1447 if (m_histstart >= n_display) m_histstart = 0;
1448 }
1449 }
1450 else
1451
1452 {
1453 if (m_numberkeep == m_keep)
1454 {
1455 histo[m_keepstart].displayON = 0;
1456 if (m_lock == 0) for (i = ++m_keepstart;; i++)
1457 {
1458 if (i >= n_display) i = 0;
1459 if (i == loadXYindex) break;
1460 if (histo[i].displayON != 0)
1461 {
1462 m_histstart = i;
1463 break;
1464 }
1465 }
1466 }
1467 }
1468 if (wrapAround)
1469 histo[loadXYindex].getMaxWindow();
1470 else
1471 histo[loadXYindex].wrapindex = 0;
1472 histIndex = loadXYindex;
1473 lastDisp = loadXYindex;
1474
1475 if (loadXYindex < 0 || loadXYindex >= n_display) return -1;
1476 if (histo[loadXYindex] != null && histo[loadXYindex].displayON != 0 && histo[loadXYindex].lockFlag == 0)
1477 {
1478 histo[loadXYindex].bindSecondaryY = bindToSecondaryAxis;
1479 }
1480
1481 prepareDraw();
1482 m_keep = 0;
1483 return (loadXYindex);
1484 }
1485 public void clearScreen()
1486 {
1487 clearScreen(-1, 0);
1488 }
1489 public void clearScreen(int hDisplay)
1490 {
1491 clearScreen(hDisplay, 0);
1492 }
1493 public void clearScreen(int hDisplay, int KeepDepth)
1494 {
1495 int i, j, num, tmp;
1496 if (aFrame.drawFlag == false) return;
1497 m_keep = KeepDepth;
1498 if (m_keep < 0 || m_keep >= n_display) m_keep = 0;
1499 num = hDisplay;
1500 if (num < 0 || num >= n_display) num = -1;
1501
1502 if (m_keep == 0 && num < 0)
1503 {
1504 if (m_lock == 0)
1505 {
1506 if (textFlag == false) drawTicks = true;
1507 aFrame.drawFlag = false;
1508 m_filled = 0;
1509 m_histstart = 0;
1510 loadXYindex = 0;
1511
1512
1513
1514
1515
1516 }
1517 for (i = 0; i < n_display; i++)
1518 if (histo[i] != null && histo[i].lockFlag == 0) histo[i].displayON = 0;
1519 }
1520 else
1521 {
1522 if (num >= 0)
1523 {
1524 if (histo[num] != null && histo[num].displayON != 0 && histo[num].lockFlag == 0)
1525 {
1526 histo[num].displayON = 0;
1527 if (num == m_histstart)
1528 {
1529 for (i = 0, j = m_histstart; i < n_display; i++, j++)
1530
1531 {
1532 if (j >= n_display) j = 0;
1533 if (histo[j] != null && histo[j].displayON != 0)
1534 {
1535 m_histstart = num;
1536 break;
1537 }
1538 }
1539 }
1540 }
1541 else if (m_keep == 0) return;
1542 }
1543 if (m_keep > n_display - m_lock) m_keep = n_display - m_lock;
1544 if (m_keep != 0)
1545 {
1546 for (m_numberkeep = tmp = j = 0, i = loadXYindex + 1; j < m_keep;)
1547 {
1548 if (--i < 0) i += n_display;
1549 if (histo[i] == null || histo[i].lockFlag == 0) j++;
1550
1551 if (histo[i] != null && histo[i].displayON != 0)
1552 {
1553 tmp++;
1554 if (histo[i].lockFlag == 0)
1555 {
1556
1557 histo[i].keephisto();
1558 m_numberkeep++;
1559 m_keepstart = i;
1560
1561 if (histo[i].dismode == AcopConst.mode_histogram
1562 || histo[i].dismode == AcopConst.mode_histogram_rastoring
1563 || histo[i].dismode == AcopConst.mode_dots || histo[i].dismode == AcopConst.mode_rectangle
1564 || histo[i].dismode == AcopConst.mode_circle) histo[i].tagHist = 0;
1565 }
1566 }
1567 }
1568 if (m_lock == 0 && m_numberkeep != 0) m_histstart = m_keepstart;
1569
1570
1571 aFrame.drawFlag = (m_lock != 0 || tmp != 0) ? true : false;
1572 if (textFlag == false && aFrame.drawFlag == false) drawTicks = true;
1573 for (j = loadXYindex + 1;; j++)
1574 {
1575 if (j >= n_display) j = 0;
1576 if (j == i) break;
1577 if (histo[j] != null && histo[j].lockFlag == 0) histo[j].displayON = 0;
1578 }
1579 }
1580 else
1581 {
1582 for (i = 0, j = m_histstart; i < n_display; i++, j++)
1583 {
1584 if (j >= n_display) j = 0;
1585 if (histo[j] != null && histo[j].displayON != 0) break;
1586 }
1587 if (i == n_display)
1588 {
1589 aFrame.drawFlag = false;
1590 if (textFlag == false) drawTicks = true;
1591 }
1592 }
1593 }
1594 if (drawTicks || histo[m_histstart].dismode >= AcopConst.mode_textbox
1595 || (aFrame.drawFlag == false && textFlag == false))
1596 this.repaint();
1597 else
1598 repaintHisto();
1599 }
1600 public void recallScreen(int hDisplay)
1601 {
1602 int num;
1603 num = hDisplay;
1604 if (num < 0 || num >= n_display) return;
1605 if (histo[num] == null) return;
1606 if (aFrame.drawFlag == false && m_lock == 0) m_histstart = num;
1607 if (histo[num].displayON == 0)
1608 {
1609
1610 histo[num].displayON = 1;
1611 aFrame.drawFlag = true;
1612 if (histo[num].dismode == AcopConst.mode_histogram
1613 || histo[num].dismode == AcopConst.mode_histogram_rastoring
1614 || histo[num].dismode == AcopConst.mode_dots || histo[num].dismode == AcopConst.mode_rectangle
1615 || histo[num].dismode == AcopConst.mode_circle)
1616 {
1617 histo[num].tagHist = 1;
1618 lastTagHisto = num;
1619 }
1620 lastDisp = num;
1621
1622 if (wrapAround && sca[0].log == 0) histo[num].setwrapindex();
1623
1624 if (drawTicks)
1625 {
1626 this.repaint();
1627 drawTicks = false;
1628 }
1629 else
1630 drawOneHist(num);
1631 }
1632 }
1633 public long lockScreen(int LockOn, int hDisplay)
1634 {
1635 int num, ende, lock, i;
1636 lock = LockOn;
1637 num = hDisplay;
1638 if (num < 0 || num >= n_display)
1639 {
1640 num = 0;
1641 ende = n_display - 1;
1642 }
1643 else
1644 {
1645 ende = num;
1646 }
1647 if (lock < 0)
1648 {
1649 if (num != ende)
1650 return m_lock;
1651 else
1652 return histo[num] != null ? histo[num].lockFlag : -1;
1653 }
1654 else if (lock > 0 && aFrame.drawFlag == false) return -1;
1655 for (i = num; num <= ende; num++)
1656 {
1657 if (histo[num] == null) continue;
1658 if (lock == 0)
1659 {
1660 if (histo[num].lockFlag == 1)
1661 {
1662 histo[num].lockFlag = 0;
1663 m_lock--;
1664 }
1665 }
1666 else if (histo[num].displayON != 0)
1667 {
1668 if (histo[num].lockFlag == 0)
1669 {
1670 histo[num].lockFlag = 1;
1671
1672 if (m_lock++ == 0 && num != m_histstart) m_histstart = num;
1673 }
1674 }
1675 }
1676 return (i != ende) ? m_lock : (histo[num] == null ? 0 : histo[ende].lockFlag);
1677 }
1678 public int printText(java.lang.String Text)
1679 {
1680 return callPrintText(Text, 0, 0, false);
1681 }
1682 public int printText(java.lang.String Text, double Xposition, double Yposition)
1683 {
1684 return callPrintText(Text, Xposition, Yposition, true);
1685 }
1686 protected int callPrintText(java.lang.String Text, double Xposition, double Yposition, boolean positionFlag)
1687 {
1688 int resca, i, firstDraw;
1689 if (Text.indexOf(13) == 0) return -1;
1690
1691 if (textFlag == true && ptext[loadTextIndex] != null && ptext[loadTextIndex].textON == true)
1692 {
1693
1694 for (i = loadTextIndex + 1, resca = 0; resca < n_text; i++, resca++)
1695 {
1696 if (i == n_text) i = 0;
1697 if (ptext[i] == null)
1698 {
1699 ptext[i] = new AcopText(this);
1700 break;
1701 }
1702 else if (ptext[i].textON == false)
1703 break;
1704 else if (reuseText) break;
1705 }
1706 if (resca < n_text)
1707 {
1708 loadTextIndex = i;
1709 }
1710 else
1711 {
1712 return -1;
1713 }
1714 }
1715 firstDraw = 0;
1716 if (ptext[loadTextIndex] == null)
1717 {
1718 ptext[loadTextIndex] = new AcopText(this);
1719 if (loadTextIndex == 0 && aFrame.drawFlag == false)
1720 {
1721 firstDraw = 1;
1722 setlimit();
1723 sca[0].scaleToGrid();
1724 for (i = 0; i < 3; i++)
1725 sca[i].xyscale(true);
1726 scaleframe();
1727 aFrame.xleft = 0;
1728 aFrame.xright = aFrame.histRect.width;
1729 aFrame.dxwidth = aFrame.xright - aFrame.xleft;
1730 aFrame.absxleft = aFrame.xleft + aFrame.histRect.x;
1731 }
1732 }
1733 if (positionFlag == false)
1734 {
1735 Xposition = lastTextx;
1736 Yposition = lastTexty;
1737 }
1738 if (ptext[loadTextIndex].printText(Text, Xposition, Yposition, foreColor, getFont()) == 0)
1739 {
1740
1741
1742
1743
1744 lastTextx = ptext[loadTextIndex].lastTextx;
1745 lastTexty = ptext[loadTextIndex].lastTexty;
1746 if (firstDraw != 0) repaint();
1747
1748
1749
1750
1751
1752
1753 return (loadTextIndex);
1754 }
1755 return -1;
1756 }
1757 public void clearText()
1758 {
1759 clearText(-1);
1760 }
1761 public void clearText(int hText)
1762 {
1763 int start, ende, i, cnt;
1764 start = hText;
1765 if (start < 0 || start >= n_text)
1766 {
1767 start = 0;
1768 ende = n_text - 1;
1769 }
1770 else
1771 ende = start;
1772 for (cnt = 0, i = 0; i < n_text; i++)
1773 {
1774 if (ptext[i] == null) continue;
1775 if (ptext[i].textON == false) continue;
1776 if (i >= start && i <= ende)
1777 {
1778 ptext[i].textON = false;
1779 if (ptext[i].outside == false)
1780 this.repaint(ptext[i].textRect.x, ptext[i].textRect.y, ptext[i].textRect.width,
1781 ptext[i].textRect.height);
1782 }
1783 else
1784 cnt++;
1785 }
1786 textFlag = cnt != 0 ? true : false;
1787 if (textFlag == false)
1788 {
1789
1790 if (aFrame.drawFlag == false)
1791 {
1792 this.repaint();
1793 drawTicks = true;
1794 }
1795 }
1796 if (start != ende) loadTextIndex = 0;
1797 }
1798 public void recallText(int hText)
1799 {
1800 int start;
1801 start = hText;
1802 if (start < 0 || start >= n_text) return;
1803 if (ptext[start] == null || ptext[start].textON == true) return;
1804
1805
1806 textFlag = true;
1807 ptext[start].textON = true;
1808 ptext[start].rescaleText(0);
1809 if (ptext[start].outside == true) return;
1810 if (drawTicks)
1811 {
1812 this.repaint();
1813 drawTicks = false;
1814 }
1815 else
1816 ptext[start].printUserText(null);
1817 }
1818 public int refreshText(java.lang.String Text, int hText)
1819 {
1820 if (hText < 0 || hText >= n_text || ptext[hText] == null) return -1;
1821 ptext[hText].refreshText(Text);
1822 return hText;
1823 }
1824 public void setAveragingDepth(int averagingDepth)
1825 {
1826 if (this.averagingDepth == averagingDepth) return;
1827 if (averagingDepth < 2 || averagingDepth > AcopConst.N_DEF_DISPLAY) averagingDepth = 0;
1828 averagingIndex = 0;
1829 averagingLength = 0;
1830 NumberAveragingData = 0;
1831 int oldValue = this.averagingDepth;
1832 this.averagingDepth = averagingDepth;
1833 firePropertyChange("averagingDepth", oldValue, this.averagingDepth);
1834 }
1835 public int getAveragingDepth()
1836 {
1837 return this.averagingDepth;
1838 }
1839 public void setAveragingMode(int averagingMode)
1840 {
1841 if (this.averagingMode == averagingMode || averagingMode < 0 || averagingMode > 1) return;
1842 int oldValue = this.averagingMode;
1843 this.averagingMode = averagingMode;
1844 firePropertyChange("averagingMode", oldValue, this.averagingMode);
1845 }
1846 public int getAveragingMode()
1847 {
1848 return this.averagingMode;
1849 }
1850 public void setCaption(java.lang.String caption)
1851 {
1852
1853 captionChanged = true;
1854 String oldValue = this.caption;
1855 this.caption = caption;
1856 this.repaint(titleRect.x, titleRect.y, titleRect.width, titleRect.height);
1857 firePropertyChange("caption", oldValue, this.caption);
1858 }
1859 public java.lang.String getCaption()
1860 {
1861 return this.caption;
1862 }
1863 public void setCaptionLocation(int captionPosition)
1864 {
1865 if (this.captionPosition == captionPosition) return;
1866 int oldValue = this.captionPosition;
1867 this.captionPosition = captionPosition;
1868 this.repaint(titleRect.x, titleRect.y, titleRect.width, titleRect.height);
1869 firePropertyChange("captionPosition", oldValue, this.captionPosition);
1870 }
1871 public int getCaptionLocation()
1872 {
1873 return this.captionPosition;
1874 }
1875 public void setDisplayMode(int displayMode)
1876
1877 {
1878 if (this.displayMode == displayMode) return;
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888 if (displayMode < AcopConst.mode_polyline || displayMode > AcopConst.mode_barline_histo_dots) return;
1889 int oldValue = this.displayMode;
1890 this.displayMode = displayMode;
1891 setGlobalDisplayMode();
1892 if (randomData == true)
1893 {
1894 rescaleFlag = 2;
1895 prepareDraw();
1896 }
1897 firePropertyChange("displayMode", oldValue, this.displayMode);
1898 }
1899 public int getDisplayMode()
1900 {
1901 return this.displayMode;
1902 }
1903 public void setDrawWidth(int drawWidth)
1904 {
1905 if (this.drawWidth == drawWidth) return;
1906 if (drawWidth < 1) drawWidth = 1;
1907 int oldValue = this.drawWidth;
1908 this.drawWidth = drawWidth;
1909 if (randomData == true) repaintHisto();
1910
1911 firePropertyChange("drawWidth", oldValue, this.drawWidth);
1912 }
1913 public int getDrawWidth()
1914 {
1915 return this.drawWidth;
1916 }
1917 private void checkRange(int flag, double value)
1918 {
1919 if ( flag == 1 )
1920 {
1921 if (sca[0].usermax <= value + AcopConst.zero_check)
1922 {
1923 if (Math.abs(value) < AcopConst.zero_check)
1924 sca[0].usermax = value + 10;
1925 else
1926 sca[0].usermax = value + 0.5 * Math.abs(value);
1927 }
1928 sca[0].setUserscale(value, sca[0].usermax);
1929 }
1930 else if ( flag == 2 )
1931 {
1932 if (value <= sca[0].usermin + AcopConst.zero_check)
1933 {
1934 if (Math.abs(value) < AcopConst.zero_check)
1935 sca[0].usermin = value - 10;
1936 else
1937 sca[0].usermin = value - 0.5 * Math.abs(value);
1938 }
1939 sca[0].setUserscale(sca[0].usermin, value);
1940 }
1941 else if ( flag == 3 )
1942 {
1943 if (sca[1].usermax <= value + AcopConst.zero_check)
1944 {
1945 if (Math.abs(value) < AcopConst.zero_check)
1946 sca[1].usermax = value + 10;
1947 else
1948 sca[1].usermax = value + 0.5 * Math.abs(value);
1949 }
1950 sca[1].setUserscale(value, sca[1].usermax);
1951 }
1952 else if ( flag == 4 )
1953 {
1954 if (value <= sca[1].usermin + AcopConst.zero_check)
1955 {
1956 if (Math.abs(value) < AcopConst.zero_check)
1957 sca[1].usermin = value - 10;
1958 else
1959 sca[1].usermin = value - 0.5 * Math.abs(value);
1960 }
1961 sca[1].setUserscale(sca[1].usermin, value);
1962 }
1963 }
1964 public void setXRange(double xMin, double xMax)
1965 {
1966 if (Math.abs(sca[0].usermin - xMin) < AcopConst.zero_check) return;
1967 if (Math.abs(sca[0].usermax - xMax) < AcopConst.zero_check) return;
1968 double oldValue = sca[0].usermin;
1969 double oldValueMax = sca[0].usermax;
1970 drawTicks = true;
1971 checkRange(1, xMin);
1972 checkRange(2, xMax);
1973 rescaleFlag = 2;
1974 rescaleTextFlag = AcopConst.NEW_ZOOM_WINDOW;
1975 prepareDraw();
1976 firePropertyChange("xMin", oldValue, sca[0].usermin);
1977 firePropertyChange("xMax", oldValueMax, sca[0].usermax);
1978 }
1979 public void setYRange(double yMin, double yMax)
1980 {
1981 if (Math.abs(sca[1].usermin - yMin) < AcopConst.zero_check) return;
1982 if (Math.abs(sca[1].usermax - yMax) < AcopConst.zero_check) return;
1983 double oldValue = sca[1].usermin;
1984 double oldValueMax = sca[1].usermax;
1985 drawTicks = true;
1986 checkRange(3, yMin);
1987 checkRange(4, yMax);
1988 rescaleFlag = 2;
1989 rescaleTextFlag = AcopConst.NEW_ZOOM_WINDOW;
1990 prepareDraw();
1991 firePropertyChange("yMin", oldValue, sca[1].usermin);
1992 firePropertyChange("yMax", oldValueMax, sca[1].usermax);
1993 }
1994 public void setXYRange(double xMin, double xMax, double yMin, double yMax)
1995 {
1996 if (Math.abs(sca[0].usermin - xMin) < AcopConst.zero_check) return;
1997 if (Math.abs(sca[0].usermax - xMax) < AcopConst.zero_check) return;
1998 if (Math.abs(sca[1].usermin - yMin) < AcopConst.zero_check) return;
1999 if (Math.abs(sca[1].usermax - yMax) < AcopConst.zero_check) return;
2000 double oldValue = sca[0].usermin;
2001 double oldValueMax = sca[0].usermax;
2002 double oldValueY = sca[1].usermin;
2003 double oldValueYMax = sca[1].usermax;
2004 drawTicks = true;
2005 checkRange(1, xMin);
2006 checkRange(2, xMax);
2007 checkRange(3, yMin);
2008 checkRange(4, yMax);
2009 rescaleFlag = 2;
2010 rescaleTextFlag = AcopConst.NEW_ZOOM_WINDOW;
2011 prepareDraw();
2012 firePropertyChange("xMin", oldValue, sca[0].usermin);
2013 firePropertyChange("xMax", oldValueMax, sca[0].usermax);
2014 firePropertyChange("yMin", oldValueY, sca[1].usermin);
2015 firePropertyChange("yMax", oldValueYMax, sca[1].usermax);
2016 }
2017 public void setXMin(double xMin)
2018 {
2019 if (Math.abs(sca[0].usermin - xMin) < AcopConst.zero_check) return;
2020 double oldValue = sca[0].usermin;
2021 drawTicks = true;
2022 if (sca[0].usermax <= xMin + AcopConst.zero_check)
2023 {
2024 if (Math.abs(xMin) < AcopConst.zero_check)
2025 sca[0].usermax = xMin + 10;
2026 else
2027 sca[0].usermax = xMin + 0.5 * Math.abs(xMin);
2028 }
2029
2030 sca[0].setUserscale(xMin, sca[0].usermax);
2031 rescaleFlag = 2;
2032 rescaleTextFlag = AcopConst.NEW_ZOOM_WINDOW;
2033 prepareDraw();
2034 firePropertyChange("xMin", oldValue, sca[0].usermin);
2035
2036 }
2037 public double getXMin()
2038 {
2039 return sca[0].usermin;
2040 }
2041 public void setXMax(double xMax)
2042 {
2043 if (Math.abs(sca[0].usermax - xMax) < AcopConst.zero_check) return;
2044 double oldValue = sca[0].usermax;
2045 drawTicks = true;
2046 if (xMax <= sca[0].usermin + AcopConst.zero_check)
2047 {
2048 if (Math.abs(xMax) < AcopConst.zero_check)
2049 sca[0].usermin = xMax - 10;
2050 else
2051 sca[0].usermin = xMax - 0.5 * Math.abs(xMax);
2052 }
2053
2054 sca[0].setUserscale(sca[0].usermin, xMax);
2055 rescaleFlag = 2;
2056 rescaleTextFlag = AcopConst.NEW_ZOOM_WINDOW;
2057 prepareDraw();
2058 firePropertyChange("xMax", oldValue, sca[0].usermax);
2059 }
2060 public double getXMax()
2061 {
2062 return sca[0].usermax;
2063 }
2064 public void setYMin(double yMin)
2065 {
2066 if (Math.abs(sca[1].usermin - yMin) < AcopConst.zero_check) return;
2067 double oldValue = sca[1].usermin;
2068 if (m_marker == 2) setmarkerflag(2);
2069 drawTicks = true;
2070 if (sca[1].usermax <= yMin + AcopConst.zero_check)
2071 {
2072 if (Math.abs(yMin) < AcopConst.zero_check)
2073 sca[1].usermax = yMin + 10;
2074 else
2075 sca[1].usermax = yMin + 0.5 * Math.abs(yMin);
2076 }
2077
2078 sca[1].setUserscale(yMin, sca[1].usermax);
2079 rescaleFlag = 2;
2080 rescaleTextFlag = AcopConst.NEW_ZOOM_WINDOW;
2081 prepareDraw();
2082 firePropertyChange("yMin", oldValue, sca[1].usermin);
2083 }
2084 public double getYMin()
2085 {
2086 return sca[1].usermin;
2087 }
2088 public void setYMax(double yMax)
2089 {
2090 if (Math.abs(sca[1].usermax - yMax) < AcopConst.zero_check) return;
2091 double oldValue = sca[1].usermax;
2092 if (m_marker == 2) setmarkerflag(2);
2093 drawTicks = true;
2094 if (yMax <= sca[1].usermin + AcopConst.zero_check)
2095 {
2096 if (Math.abs(yMax) < AcopConst.zero_check)
2097 sca[1].usermin = yMax - 10;
2098 else
2099 sca[1].usermin = yMax - 0.5 * Math.abs(yMax);
2100 }
2101
2102 sca[1].setUserscale(sca[1].usermin, yMax);
2103 rescaleFlag = 2;
2104 rescaleTextFlag = AcopConst.NEW_ZOOM_WINDOW;
2105 prepareDraw();
2106 firePropertyChange("yMax", oldValue, sca[1].usermax);
2107 }
2108 public double getYMax()
2109 {
2110 return sca[1].usermax;
2111 }
2112 public void setSecondaryYMin(double SecondaryYMin)
2113 {
2114 if (Math.abs(sca[2].usermin - SecondaryYMin) < AcopConst.zero_check) return;
2115 double oldValue = sca[2].usermin;
2116 if (sca[2].usermax <= SecondaryYMin + AcopConst.zero_check)
2117 {
2118 if (Math.abs(SecondaryYMin) < AcopConst.zero_check)
2119 sca[2].usermax = SecondaryYMin + 10;
2120 else
2121 sca[2].usermax = SecondaryYMin + 0.5 * Math.abs(SecondaryYMin);
2122 }
2123
2124 sca[2].setUserscale(SecondaryYMin, sca[2].usermax);
2125 rescaleFlag = 2;
2126 rescaleTextFlag = AcopConst.NEW_ZOOM_WINDOW;
2127 prepareDraw();
2128 firePropertyChange("secondaryYMin", oldValue, SecondaryYMin);
2129 }
2130 public double getSecondaryYMin()
2131 {
2132 return sca[2].usermin;
2133 }
2134 public void setSecondaryYMax(double setSecondaryYMax)
2135 {
2136 if (Math.abs(sca[2].usermax - setSecondaryYMax) < AcopConst.zero_check) return;
2137 double oldValue = sca[2].usermax;
2138 if (setSecondaryYMax <= sca[2].usermin + AcopConst.zero_check)
2139 {
2140 if (Math.abs(setSecondaryYMax) < AcopConst.zero_check)
2141 sca[2].usermin = setSecondaryYMax - 10;
2142 else
2143 sca[2].usermin = setSecondaryYMax - 0.5 * Math.abs(setSecondaryYMax);
2144 }
2145
2146 sca[2].setUserscale(sca[2].usermin, setSecondaryYMax);
2147 rescaleFlag = 2;
2148 rescaleTextFlag = AcopConst.NEW_ZOOM_WINDOW;
2149 prepareDraw();
2150 firePropertyChange("secondaryYMax", oldValue, setSecondaryYMax);
2151 }
2152 public double getSecondaryYMax()
2153 {
2154 return sca[2].usermax;
2155 }
2156 private void scaleFrameDraw()
2157 {
2158 scaleframe();
2159
2160 drawTicks = true;
2161 rescaleTextFlag = AcopConst.NEW_TEXT_WINDOW;
2162 if (aFrame.drawFlag)
2163 prepareDraw();
2164 else
2165 changeScaleWidth = 0;
2166 }
2167 public void setFrameWidth(int frameWidth)
2168 {
2169 if (this.frameWidth == frameWidth) return;
2170 int oldValue = this.frameWidth;
2171 this.frameWidth = frameWidth;
2172 scaleFrameDraw();
2173 firePropertyChange("frameWidth", oldValue, this.frameWidth);
2174 }
2175 public int getFrameWidth()
2176 {
2177 return this.frameWidth;
2178 }
2179 public void setFrameLeftOffset(int frameLeftOffset)
2180 {
2181 if (this.frameLeftOffset == frameLeftOffset) return;
2182 int oldValue = this.frameLeftOffset;
2183 this.frameLeftOffset = frameLeftOffset;
2184 scaleFrameDraw();
2185 firePropertyChange("frameLeftOffset", oldValue, this.frameLeftOffset);
2186 }
2187 public int getFrameLeftOffset()
2188 {
2189 return this.frameLeftOffset;
2190 }
2191 public void setFrameRightOffset(int frameRightOffset)
2192 {
2193 if (this.frameRightOffset == frameRightOffset) return;
2194 int oldValue = this.frameRightOffset;
2195 this.frameRightOffset = frameRightOffset;
2196 scaleFrameDraw();
2197 firePropertyChange("frameRightOffset", oldValue, this.frameRightOffset);
2198 }
2199 public int getFrameRightOffset()
2200 {
2201 return this.frameRightOffset;
2202 }
2203 public void setFrameTopOffset(int frameTopOffset)
2204 {
2205 if (this.frameTopOffset == frameTopOffset) return;
2206 int oldValue = this.frameTopOffset;
2207 this.frameTopOffset = frameTopOffset;
2208 scaleFrameDraw();
2209 firePropertyChange("frameTopOffset", oldValue, this.frameTopOffset);
2210 }
2211 public int getFrameTopOffset()
2212 {
2213 return this.frameTopOffset;
2214 }
2215 public void setFrameBottomOffset(int frameBottomOffset)
2216 {
2217 if (this.frameBottomOffset == frameBottomOffset) return;
2218 int oldValue = this.frameBottomOffset;
2219 this.frameBottomOffset = frameBottomOffset;
2220 scaleFrameDraw();
2221 firePropertyChange("frameBottmOffset", oldValue, this.frameBottomOffset);
2222 }
2223 public int getFrameBottomOffset()
2224 {
2225 return this.frameBottomOffset;
2226 }
2227 public void setFrameForeColor(java.awt.Color frameForeColor)
2228 {
2229 if (aFrame.frameForeColor != null && aFrame.frameForeColor.equals(frameForeColor)) return;
2230 Color oldValue = aFrame.frameForeColor;
2231 aFrame.frameForeColor = frameForeColor;
2232 this.repaint();
2233 firePropertyChange("frameForColor", oldValue, aFrame.frameForeColor);
2234 }
2235 public java.awt.Color getFrameForeColor()
2236 {
2237 return aFrame.frameForeColor;
2238 }
2239 public void setXTickLabelColor(java.awt.Color xTickLabelColor)
2240 {
2241 if (sca[0].tickLabelForeColor != null && sca[0].tickLabelForeColor.equals(xTickLabelColor)) return;
2242 Color oldValue = sca[0].tickLabelForeColor;
2243 sca[0].tickLabelForeColor = xTickLabelColor;
2244 this.repaint(sca[0].ticksRect.x, sca[0].ticksRect.y, sca[0].ticksRect.width, sca[0].ticksRect.height);
2245 if (sca[0].leftBottom != sca[0].leftBottLabel)
2246 this.repaint(sca[0].labelRect.x, sca[0].labelRect.y, sca[0].labelRect.width, sca[0].labelRect.height);
2247 firePropertyChange("xTickLabelColor", oldValue, sca[0].tickLabelForeColor);
2248 }
2249 public java.awt.Color getXTickLabelColor()
2250 {
2251 return sca[0].tickLabelForeColor;
2252 }
2253 public void setYTickLabelColor(java.awt.Color yTickLabelColor)
2254 {
2255 if (sca[1].tickLabelForeColor != null && sca[1].tickLabelForeColor.equals(yTickLabelColor)) return;
2256 Color oldValue = sca[1].tickLabelForeColor;
2257 sca[1].tickLabelForeColor = yTickLabelColor;
2258 this.repaint(sca[1].ticksRect.x, sca[1].ticksRect.y, sca[1].ticksRect.width, sca[1].ticksRect.height);
2259 if (sca[1].leftBottom != sca[1].leftBottLabel)
2260 this.repaint(sca[1].labelRect.x, sca[1].labelRect.y, sca[1].labelRect.width, sca[1].labelRect.height);
2261 firePropertyChange("yTickLabelColor", oldValue, sca[1].tickLabelForeColor);
2262 }
2263 public java.awt.Color getYTickLabelColor()
2264 {
2265 return sca[1].tickLabelForeColor;
2266 }
2267 public void setSecondaryYTickLabelColor(java.awt.Color secondaryYTickLabelColor)
2268 {
2269 if (sca[2].tickLabelForeColor != null && sca[2].tickLabelForeColor.equals(secondaryYTickLabelColor)) return;
2270 Color oldValue = sca[2].tickLabelForeColor;
2271 sca[2].tickLabelForeColor = secondaryYTickLabelColor;
2272 firePropertyChange("secondaryYTickLabelColor", oldValue, sca[2].tickLabelForeColor);
2273 if (sca[2].OnFlag == false) return;
2274 this.repaint(sca[2].ticksRect.x, sca[2].ticksRect.y, sca[2].ticksRect.width, sca[2].ticksRect.height);
2275 if (sca[2].leftBottom != sca[2].leftBottLabel)
2276 this.repaint(sca[2].labelRect.x, sca[2].labelRect.y, sca[2].labelRect.width, sca[2].labelRect.height);
2277
2278 }
2279 public java.awt.Color getSecondaryYTickLabelColor()
2280 {
2281 return sca[2].tickLabelForeColor;
2282 }
2283 public void setSecondaryYAxisOn(boolean secondaryYAxisOn)
2284 {
2285 if (sca[2].OnFlag == secondaryYAxisOn) return;
2286 sca[2].OnFlag = secondaryYAxisOn;
2287 rescaleFlag = 2;
2288 rescaleTextFlag = AcopConst.NEW_ZOOM_WINDOW;
2289 if (aFrame.drawFlag == false) return;
2290 prepareDraw();
2291 firePropertyChange("secondaryYAxisOn", !secondaryYAxisOn, secondaryYAxisOn);
2292 }
2293 public boolean isSecondaryYAxisOn()
2294 {
2295 return sca[2].OnFlag;
2296 }
2297 public void setSecondaryYLogOn(boolean secondaryYLogOn)
2298 {
2299 int temp = secondaryYLogOn ? 1 : 0 ;
2300 if (temp == sca[2].log) return;
2301 int oldValue = sca[2].log;
2302 sca[2].log = temp;
2303 rescaleFlag = 2;
2304 rescaleTextFlag = AcopConst.NEW_ZOOM_WINDOW;
2305 if (aFrame.drawFlag == false) return;
2306 prepareDraw();
2307 firePropertyChange("secondaryYLogOn", oldValue, sca[2].log);
2308 }
2309 public boolean isSecondaryYLogOn()
2310 {
2311 return sca[2].log != 0 ? true : false ;
2312 }
2313 public void setFrameFont(java.awt.Font frameFont)
2314 {
2315 if (aFrame.frameFont != null && aFrame.frameFont.equals(frameFont)) return;
2316 Font oldValue = aFrame.frameFont;
2317 aFrame.frameFont = frameFont;
2318 this.repaint();
2319 firePropertyChange("frameFont", oldValue, aFrame.frameFont);
2320 }
2321 public java.awt.Font getFrameFont()
2322 {
2323 return aFrame.frameFont;
2324 }
2325 public void setDrawStyle(int drawStyle)
2326
2327 {
2328 if (this.drawStyle != drawStyle)
2329 {
2330
2331
2332
2333
2334
2335
2336 if (drawStyle < AcopConst.PS_SOLID || drawStyle > AcopConst.PS_DASH_DOT) return;
2337 int oldValue = this.drawStyle;
2338 this.drawStyle = drawStyle;
2339 if (randomData == true)
2340 {
2341 rescaleFlag = 2;
2342 prepareDraw();
2343 }
2344 firePropertyChange("drawStyle", oldValue, this.drawStyle);
2345 }
2346 }
2347 public int getDrawStyle()
2348 {
2349 return this.drawStyle;
2350 }
2351 public void setFFT(int fFT)
2352 {
2353 if (fFT < 0 || fFT > AcopConst.FFT_RI_INVERSE) fFT = 0;
2354 if (this.FFT == fFT) return;
2355 int oldValue = this.FFT;
2356 this.FFT = fFT;
2357 if (randomData == true)
2358 {
2359 rescaleFlag = 2;
2360 prepareDraw();
2361 }
2362 firePropertyChange("fFT", oldValue, this.FFT);
2363 }
2364 public int getFFT()
2365 {
2366 return this.FFT;
2367 }
2368 public void setGraphStyle(int graphStyle)
2369 {
2370 int changeYlog = 0;
2371 if (this.graphStyle == graphStyle) return;
2372 int oldValue = this.graphStyle;
2373 if (graphStyle < 0 || graphStyle > 5) graphStyle = 0;
2374 switch (graphStyle)
2375 {
2376 default:
2377 case 0:
2378 if (sca[1].log != 0) changeYlog = 1;
2379 sca[0].log = 0;
2380 sca[1].log = 0;
2381 sca[0].xtime = 0;
2382 break;
2383 case 1:
2384 if (sca[1].log == 0) changeYlog = 1;
2385 sca[0].log = 0;
2386 sca[1].log = 1;
2387 sca[0].xtime = 0;
2388 break;
2389 case 2:
2390 if (sca[1].log != 0) changeYlog = 1;
2391 sca[0].log = 1;
2392 sca[1].log = 0;
2393 sca[0].xtime = 0;
2394 break;
2395 case 3:
2396 if (sca[1].log == 0) changeYlog = 1;
2397 sca[0].log = 1;
2398 sca[1].log = 1;
2399 sca[0].xtime = 0;
2400 break;
2401 case 4:
2402 if (sca[1].log != 0) changeYlog = 1;
2403 sca[0].log = 0;
2404 sca[1].log = 0;
2405 sca[0].xtime = 1;
2406 break;
2407 case 5:
2408 if (sca[1].log == 0) changeYlog = 1;
2409 sca[0].log = 0;
2410 sca[1].log = 1;
2411 sca[0].xtime = 1;
2412 break;
2413 }
2414 if (changeYlog != 0 && m_marker == 2) setmarkerflag(2);
2415
2416 this.graphStyle = graphStyle;
2417 rescaleFlag = 2;
2418 rescaleTextFlag = AcopConst.NEW_ZOOM_WINDOW;
2419 prepareDraw();
2420 firePropertyChange("graphStyle", oldValue, this.graphStyle);
2421 }
2422 public int getGraphStyle()
2423 {
2424 return this.graphStyle;
2425 }
2426 public void setGridStyle(int gridStyle)
2427 {
2428 if (AcopScale.gridLineMode == gridStyle) return;
2429 int oldValue = AcopScale.gridLineMode;
2430 AcopScale.gridLineMode = gridStyle;
2431 AcopScale.gridStroke = AcopConst.createStroke(AcopScale.gridLineWidth, AcopScale.gridLineMode);
2432 if (aFrame.drawFlag) repaintHisto();
2433 firePropertyChange("gridStyle", oldValue, AcopScale.gridLineMode);
2434 }
2435 public int getGridStyle()
2436 {
2437 return AcopScale.gridLineMode;
2438 }
2439 public void setGridColor(java.awt.Color gridColor)
2440 {
2441 if (AcopScale.gridLineColor == gridColor) return;
2442 Color oldValue = AcopScale.gridLineColor;
2443 AcopScale.gridLineColor = gridColor;
2444 AcopScale.gridStroke = AcopConst.createStroke(AcopScale.gridLineWidth, AcopScale.gridLineMode);
2445 if (aFrame.drawFlag) repaintHisto();
2446 firePropertyChange("gridColor", oldValue, AcopScale.gridLineColor);
2447 }
2448 public java.awt.Color getGridColor()
2449 {
2450 return AcopScale.gridLineColor;
2451 }
2452 public void setGridWidth(int gridWidth)
2453 {
2454 if (AcopScale.gridLineWidth == gridWidth) return;
2455 if (gridWidth < 1) gridWidth = 1;
2456 int oldValue = AcopScale.gridLineWidth;
2457 AcopScale.gridLineWidth = gridWidth;
2458 AcopScale.gridStroke = AcopConst.createStroke(AcopScale.gridLineWidth, AcopScale.gridLineMode);
2459 if (aFrame.drawFlag) repaintHisto();
2460 firePropertyChange("gridWidth", oldValue, AcopScale.gridLineWidth);
2461 }
2462 public int getGridWidth()
2463 {
2464 return AcopScale.gridLineWidth;
2465 }
2466 public void setKeepStyle(int keepStyle)
2467 {
2468 if (this.keepStyle == keepStyle) return;
2469 int oldValue = this.keepStyle;
2470 this.keepStyle = keepStyle;
2471 if (aFrame.drawFlag && m_keep != 0) repaintHisto();
2472 firePropertyChange("keepStyle", oldValue, this.keepStyle);
2473 }
2474 public int getKeepStyle()
2475 {
2476 return this.keepStyle;
2477 }
2478 public void setKeepColor(java.awt.Color keepColor)
2479 {
2480 if (this.keepColor != null && this.keepColor.equals(keepColor)) return;
2481 Color oldValue = this.keepColor;
2482 this.keepColor = keepColor;
2483 if (aFrame.drawFlag && m_keep != 0) repaintHisto();
2484 firePropertyChange("keepColor", oldValue, this.keepColor);
2485 }
2486 public java.awt.Color getKeepColor()
2487 {
2488 return this.keepColor;
2489 }
2490 public void setKeepWidth(int keepWidth)
2491 {
2492 if (keepWidth == this.keepWidth) return;
2493 if (keepWidth < 1) keepWidth = 1;
2494 int oldValue = this.keepWidth;
2495 this.keepWidth = keepWidth;
2496 if (aFrame.drawFlag && m_keep != 0) repaintHisto();
2497 firePropertyChange("keepWidth", oldValue, this.keepWidth);
2498 }
2499 public int getKeepWidth()
2500 {
2501 return this.keepWidth;
2502 }
2503 public void setHistogramPosition(int histogramPosition)
2504 {
2505 if (aFrame.histogramPosition == histogramPosition) return;
2506 int oldValue = aFrame.histogramPosition;
2507 aFrame.histogramPosition = histogramPosition;
2508 if (randomData == true)
2509 {
2510 rescaleFlag = 2;
2511 prepareDraw();
2512 }
2513 firePropertyChange("histogramPosition", oldValue, aFrame.histogramPosition);
2514 }
2515 public int getHistogramPosition()
2516 {
2517 return aFrame.histogramPosition;
2518 }
2519 public void setInvert(boolean invert)
2520 {
2521 if (this.invert == invert) return;
2522 this.invert = invert;
2523 if (randomData == true)
2524 {
2525 rescaleFlag = 2;
2526 prepareDraw();
2527 }
2528 firePropertyChange("invert", !this.invert, this.invert);
2529 }
2530 public boolean isInvert()
2531 {
2532 return this.invert;
2533 }
2534
2535 public void setFrameBorderOn(boolean frameBorderOn)
2536 {
2537 if (this.frameBorderOn == frameBorderOn) return;
2538 this.frameBorderOn = frameBorderOn;
2539 if (randomData == true)
2540 {
2541 rescaleFlag = 2;
2542 prepareDraw();
2543 }
2544 firePropertyChange("frameBorderOn", !this.frameBorderOn, this.frameBorderOn);
2545 }
2546 public boolean isFrameBorderOn()
2547 {
2548 return this.frameBorderOn;
2549 }
2550
2551 public void setRandomData(boolean randomData)
2552 {
2553 if (this.randomData == randomData) return;
2554 this.randomData = randomData;
2555 if (randomData)
2556 {
2557 rescaleFlag = 2;
2558 prepareDraw();
2559 }
2560 else
2561 clearScreen(-1, 0);
2562
2563 firePropertyChange("randomData", !randomData, randomData);
2564 }
2565 public boolean isRandomData()
2566 {
2567 return this.randomData;
2568 }
2569 public void setRandomText(boolean randomText)
2570 {
2571 if (this.randomText == randomText) return;
2572 this.randomText = randomText;
2573 if (randomData)
2574 {
2575 rescaleFlag = 2;
2576 prepareDraw();
2577 }
2578 else
2579 clearScreen(-1, 0);
2580 firePropertyChange("randomText", !randomText, randomText);
2581 }
2582 public boolean isRandomText()
2583 {
2584 return this.randomText;
2585 }
2586 public void setReuseScreen(boolean reuseScreen)
2587 {
2588 if (this.reuseScreen == reuseScreen) return;
2589 this.reuseScreen = reuseScreen;
2590 firePropertyChange("reuseScreen", !reuseScreen, reuseScreen);
2591 }
2592 public boolean isReuseScreen()
2593 {
2594 return this.reuseScreen;
2595 }
2596 public void setReuseText(boolean reuseText)
2597 {
2598 if (this.reuseText == reuseText) return;
2599 this.reuseText = reuseText;
2600 firePropertyChange("reuseText", !reuseText, reuseText);
2601 }
2602 public boolean isReuseText()
2603 {
2604 return this.reuseText;
2605 }
2606 public void setScreenDepth(int screenDepth)
2607 {
2608 if (this.screenDepth == screenDepth) return;
2609
2610 int itmp = screenDepth;
2611
2612
2613 if (itmp > AcopConst.MAX_DISPLAY)
2614 itmp = AcopConst.MAX_DISPLAY;
2615 else if (itmp < 1) itmp = 1;
2616 if (histo[itmp - 1] != null) return;
2617 screenDepth = itmp;
2618 int oldValue = this.screenDepth;
2619 n_display = screenDepth;
2620 this.screenDepth = screenDepth;
2621 firePropertyChange("screenDepth", oldValue, this.screenDepth);
2622 }
2623 public int getScreenDepth()
2624 {
2625 return this.screenDepth;
2626 }
2627 public void setTextDepth(int textDepth)
2628 {
2629
2630 int itmp = textDepth;
2631
2632
2633 if (itmp > AcopConst.MAX_TEXT)
2634 itmp = AcopConst.MAX_TEXT;
2635 else if (itmp < 1) itmp = 1;
2636 if (ptext[itmp - 1] != null) return;
2637 textDepth = itmp;
2638 if (this.textDepth == textDepth) return;
2639 n_text = textDepth;
2640 int oldValue = this.textDepth;
2641 this.textDepth = textDepth;
2642 firePropertyChange("textDepth", oldValue, this.textDepth);
2643 }
2644 public int getTextDepth()
2645 {
2646 return this.textDepth;
2647 }
2648 public void setWrapAround(boolean wrapAround)
2649 {
2650 int i;
2651 if (this.wrapAround == wrapAround) return;
2652 this.wrapAround = wrapAround;
2653 if (wrapAround) for (i = 0; i < n_display; i++)
2654 if (histo[i] != null && histo[i].displayON != 0)
2655 histo[i].getMaxWindow();
2656 else
2657 for (i = 0; i < n_display; i++)
2658 if (histo[i] != null && histo[i].displayON != 0) histo[i].wrapindex = 0;
2659 if (aFrame.drawFlag || textFlag)
2660 {
2661
2662
2663 rescaleFlag = wrapAround == false ? 2 : 0;
2664 rescaleTextFlag = wrapAround == false ? AcopConst.NEW_ZOOM_WINDOW : 0;
2665 prepareDraw();
2666 }
2667 else if (wrapAround == false) drawTicks = true;
2668 firePropertyChange("wrapAround", !this.wrapAround, this.wrapAround);
2669 }
2670 public boolean isWrapAround()
2671 {
2672 return this.wrapAround;
2673 }
2674 public void setZooming(int zooming)
2675 {
2676 if (this.zooming == zooming) return;
2677 int oldValue = this.zooming;
2678 if (zooming <= 7 && zooming >= 4)
2679 zoomIndex = 0;
2680 else if (zooming < 0 || zooming > 3) zooming = 0;
2681 if ((zooming & 0x7) != 0) setZoomingWindow(zooming & 0x4);
2682 if ((zooming & 0x7) == 0 && isZoomed == true)
2683 {
2684 if (m_marker == 2) setmarkerflag(2);
2685
2686 rescaleFlag = 2;
2687 rescaleTextFlag = AcopConst.NEW_ZOOM_WINDOW;
2688 prepareDraw();
2689 isZoomed = false;
2690 zoomIndex = 0;
2691 }
2692 this.zooming = zooming;
2693 firePropertyChange("zooming", oldValue, this.zooming);
2694 }
2695 public int getZooming()
2696 {
2697 return this.zooming;
2698 }
2699 public void setXAxisLabel(java.lang.String xAxisLabel)
2700 {
2701 if (sca[0].AxisLabel != null && sca[0].AxisLabel.equals(xAxisLabel)) return;
2702 String oldValue = sca[0].AxisLabel;
2703 sca[0].AxisLabel = xAxisLabel;
2704 this.repaint(sca[0].labelRect.x, sca[0].labelRect.y, sca[0].labelRect.width, sca[0].labelRect.height);
2705 firePropertyChange("xAxisLabel", oldValue, sca[0].AxisLabel);
2706 }
2707 public java.lang.String getXAxisLabel()
2708 {
2709 return sca[0].AxisLabel;
2710 }
2711 public void setYAxisLabel(java.lang.String YAxisLabel)
2712 {
2713 if (sca[1].AxisLabel != null && sca[1].AxisLabel.equals(YAxisLabel)) return;
2714 String oldValue = sca[1].AxisLabel;
2715 sca[1].AxisLabel = YAxisLabel;
2716 this.repaint(sca[1].labelRect.x, sca[1].labelRect.y, sca[1].labelRect.width, sca[1].labelRect.height);
2717 firePropertyChange("yAxisLabel", oldValue, sca[1].AxisLabel);
2718 }
2719 public java.lang.String getYAxisLabel()
2720 {
2721 return sca[1].AxisLabel;
2722 }
2723 public void setSecondaryYAxisLabel(java.lang.String SecondaryYAxisLabel)
2724 {
2725 if (sca[2].AxisLabel != null && sca[2].AxisLabel.equals(SecondaryYAxisLabel)) return;
2726 String oldValue = sca[2].AxisLabel;
2727 sca[2].AxisLabel = SecondaryYAxisLabel;
2728 this.repaint(sca[2].labelRect.x,sca[2].labelRect.y,sca[2].labelRect.width,sca[2].labelRect.height);
2729 firePropertyChange("secondaryYAxisLabel", oldValue, sca[2].AxisLabel);
2730 }
2731
2732 public java.lang.String getSecondaryYAxisLabel()
2733 {
2734 return sca[2].AxisLabel;
2735 }
2736 public void setXBestScale(boolean XBestScale)
2737 {
2738 if (sca[0].bestScale == XBestScale) return;
2739 sca[0].bestScale = XBestScale;
2740 firePropertyChange("xBestScale", !XBestScale, XBestScale);
2741 if (sca[0].log != 0) return;
2742 rescaleFlag = 2;
2743 rescaleTextFlag = AcopConst.NEW_ZOOM_WINDOW;
2744 prepareDraw();
2745 }
2746 public boolean isXBestScale()
2747 {
2748 return sca[0].bestScale;
2749 }
2750 public void setYBestScale(boolean YBestScale)
2751 {
2752 if (sca[1].bestScale == YBestScale) return;
2753 sca[1].bestScale = YBestScale;
2754 firePropertyChange("yBestScale", !sca[1].bestScale, sca[1].bestScale);
2755 if (sca[1].log != 0) return;
2756 rescaleFlag = 2;
2757 rescaleTextFlag = AcopConst.NEW_ZOOM_WINDOW;
2758 prepareDraw();
2759 }
2760 public boolean isYBestScale()
2761 {
2762 return sca[1].bestScale;
2763 }
2764 public void setSecondaryYBestScale(boolean SecondaryYBestScale)
2765 {
2766 if (sca[2].bestScale == SecondaryYBestScale) return;
2767 sca[2].bestScale = SecondaryYBestScale;
2768 if (sca[2].log != 0) return;
2769 rescaleFlag = 2;
2770 rescaleTextFlag = AcopConst.NEW_ZOOM_WINDOW;
2771 prepareDraw();
2772 firePropertyChange("secondaryYBestScale", !SecondaryYBestScale, SecondaryYBestScale);
2773 }
2774 public boolean isSecondaryYBestScale()
2775 {
2776 return sca[2].bestScale;
2777 }
2778 public void setXExtent(double XExtent)
2779 {
2780 if (this.XExtent == XExtent) return;
2781 double oldValue = this.XExtent;
2782 this.XExtent = XExtent;
2783 if (randomData == true)
2784 {
2785 rescaleFlag = 2;
2786 prepareDraw();
2787 }
2788 firePropertyChange("xExtent", oldValue, XExtent);
2789 }
2790 public double getXExtent()
2791 {
2792 return this.XExtent;
2793 }
2794 public void setYExtent(double YExtent)
2795 {
2796 if (this.YExtent == YExtent) return;
2797 double oldValue = this.YExtent;
2798 this.YExtent = YExtent;
2799 if (randomData == true)
2800 {
2801 rescaleFlag = 2;
2802 prepareDraw();
2803 }
2804 firePropertyChange("yExtent", oldValue, this.YExtent);
2805 }
2806 public double getYExtent()
2807 {
2808 return this.YExtent;
2809 }
2810 public void setXFineTicks(int XFineTicks)
2811 {
2812 if (sca[0].fineTicks == XFineTicks) return;
2813 int oldValue = sca[0].fineTicks;
2814 sca[0].fineTicks = XFineTicks;
2815 if (randomData == true || sca[0].log == 0)
2816 {
2817 rescaleFlag = 2;
2818 prepareDraw();
2819 }
2820 firePropertyChange("xFineTicks", oldValue, sca[0].fineTicks);
2821 }
2822 public int getXFineTicks()
2823 {
2824 return sca[0].fineTicks;
2825 }
2826 public void setYFineTicks(int YFineTicks)
2827 {
2828 if (sca[1].fineTicks == YFineTicks) return;
2829 int oldValue = sca[1].fineTicks;
2830 sca[1].fineTicks = YFineTicks;
2831 if (randomData == true || sca[1].log == 0)
2832 {
2833 rescaleFlag = 2;
2834 prepareDraw();
2835 }
2836 firePropertyChange("yFineTicks", oldValue, sca[1].fineTicks);
2837 }
2838 public int getYFineTicks()
2839 {
2840 return sca[1].fineTicks;
2841 }
2842 public void setSecondaryYFineTicks(int SecondaryYFineTicks)
2843 {
2844 if (sca[2].fineTicks == SecondaryYFineTicks) return;
2845 int oldValue = sca[2].fineTicks;
2846 sca[2].fineTicks = SecondaryYFineTicks;
2847 if (randomData == true || sca[2].log == 0)
2848 {
2849 rescaleFlag = 2;
2850 prepareDraw();
2851 }
2852 firePropertyChange("secondaryYFineTicks", oldValue, sca[2].fineTicks);
2853 }
2854 public int getSecondaryYFineTicks()
2855 {
2856 return sca[2].fineTicks;
2857 }
2858 public void setXGrid(boolean XGrid)
2859 {
2860 if (sca[0].grid == XGrid) return;
2861 sca[0].grid = XGrid;
2862 repaintHisto();
2863 firePropertyChange("xGrid", !XGrid, XGrid);
2864 }
2865 public boolean isXGrid()
2866 {
2867 return sca[0].grid;
2868 }
2869 public void setYGrid(boolean YGrid)
2870 {
2871 if (sca[1].grid == YGrid) return;
2872 sca[1].grid = YGrid;
2873 repaintHisto();
2874 firePropertyChange("yGrid", !sca[1].grid, sca[1].grid);
2875 }
2876 public boolean isYGrid()
2877 {
2878 return sca[1].grid;
2879 }
2880 public void setXScale(double XScale)
2881 {
2882 if (this.XScale == XScale) return;
2883 double oldValue = this.XScale;
2884 this.XScale = XScale;
2885 if (randomData == true)
2886 {
2887 rescaleFlag = 2;
2888 prepareDraw();
2889 }
2890 firePropertyChange("xScale", oldValue, this.XScale);
2891 }
2892 public double getXScale()
2893 {
2894 return this.XScale;
2895 }
2896 public void setYScale(double YScale)
2897 {
2898 if (this.YScale == YScale) return;
2899 double oldValue = this.YScale;
2900 this.YScale = YScale;
2901 if (randomData == true)
2902 {
2903 rescaleFlag = 2;
2904 prepareDraw();
2905 }
2906 firePropertyChange("yScale", oldValue, this.YScale);
2907 }
2908 public double getYScale()
2909 {
2910 return this.YScale;
2911 }
2912 public void setXShift(double XShift)
2913 {
2914 if (this.XShift == XShift) return;
2915 double oldValue = this.XShift;
2916 this.XShift = XShift;
2917 if (randomData == true)
2918 {
2919 rescaleFlag = 2;
2920 prepareDraw();
2921 }
2922 firePropertyChange("xShift", oldValue, this.XShift);
2923 }
2924 public double getXShift()
2925 {
2926 return this.XShift;
2927 }
2928 public void setYShift(double YShift)
2929 {
2930 if (this.YShift == YShift) return;
2931 double oldValue = this.YShift;
2932 this.YShift = YShift;
2933 if (randomData == true)
2934 {
2935 rescaleFlag = 2;
2936 prepareDraw();
2937 }
2938 firePropertyChange("yShift", oldValue, this.YShift);
2939 }
2940 public double getYShift()
2941 {
2942 return this.YShift;
2943 }
2944 public void setXTicks(int XTicks)
2945 {
2946 if (sca[0].ticks == XTicks) return;
2947 int oldValue = sca[0].ticks;
2948 sca[0].ticks = XTicks;
2949 if (randomData == true || sca[0].log == 0)
2950 {
2951 rescaleFlag = 2;
2952 prepareDraw();
2953 }
2954 firePropertyChange("xTicks", oldValue, sca[0].ticks);
2955 }
2956 public int getXTicks()
2957 {
2958 return sca[0].ticks;
2959 }
2960 public void setYTicks(int YTicks)
2961 {
2962 if (sca[1].ticks == YTicks) return;
2963 int oldValue = sca[1].ticks;
2964 sca[1].ticks = YTicks;
2965 if (randomData == true || sca[1].log == 0)
2966 {
2967 rescaleFlag = 2;
2968 prepareDraw();
2969 }
2970 firePropertyChange("yTicks", oldValue, sca[1].ticks);
2971 }
2972 public int getYTicks()
2973 {
2974 return sca[1].ticks;
2975 }
2976 public void setSecondaryYTicks(int SecondaryYTicks)
2977 {
2978 if (sca[2].ticks == SecondaryYTicks) return;
2979 int oldValue = sca[2].ticks;
2980 sca[2].ticks = SecondaryYTicks;
2981 if (randomData == true || sca[2].log == 0)
2982 {
2983 rescaleFlag = 2;
2984 prepareDraw();
2985 }
2986 firePropertyChange("secondaryYTicks", oldValue, sca[2].ticks);
2987 }
2988 public int getSecondaryYTicks()
2989 {
2990 return sca[2].ticks;
2991 }
2992 public void setXTicksBottom(boolean XTicksBottom)
2993 {
2994 if (sca[0].leftBottom == XTicksBottom) return;
2995 sca[0].leftBottom = XTicksBottom;
2996 setTickRectangle(0);
2997 this.repaint();
2998 firePropertyChange("xTicksBottom", !sca[0].leftBottom, sca[0].leftBottom);
2999 }
3000 public boolean getXTicksBottom()
3001 {
3002 return sca[0].leftBottom;
3003 }
3004 public void setYTicksLeft(boolean YTicksLeft)
3005 {
3006 if (sca[1].leftBottom == YTicksLeft) return;
3007 sca[1].leftBottom = YTicksLeft;
3008 setTickRectangle(1);
3009 this.repaint();
3010 firePropertyChange("yTicksLeft", !sca[1].leftBottom, sca[1].leftBottom);
3011 }
3012 public boolean getYTicksLeft()
3013 {
3014 return sca[1].leftBottom;
3015 }
3016 public void setXTickText(boolean XTickText)
3017 {
3018 if (sca[0].ticktext == XTickText);
3019 sca[0].ticktext = XTickText;
3020 this.repaint(sca[0].ticksRect.x, sca[0].ticksRect.y, sca[0].ticksRect.width, sca[0].ticksRect.height);
3021 firePropertyChange("xTickText", !sca[0].ticktext, sca[0].ticktext);
3022 }
3023 public boolean isXTickText()
3024 {
3025 return sca[0].ticktext;
3026 }
3027 public void setYTickText(boolean YTickText)
3028 {
3029 if (sca[1].ticktext == YTickText) return;
3030 sca[1].ticktext = YTickText;
3031 this.repaint(sca[1].ticksRect.x, sca[1].ticksRect.y, sca[1].ticksRect.width, sca[1].ticksRect.height);
3032 firePropertyChange("yTickText", !sca[1].ticktext, sca[1].ticktext);
3033 }
3034 public boolean isYTickText()
3035 {
3036 return sca[1].ticktext;
3037 }
3038 public void setSecondaryYTickText(boolean SecondaryYTickText)
3039 {
3040 if (sca[2].ticktext == SecondaryYTickText) return;
3041 sca[2].ticktext = SecondaryYTickText;
3042 this.repaint(sca[2].ticksRect.x,sca[2].ticksRect.y,sca[2].ticksRect.width,sca[2].ticksRect.height);
3043 firePropertyChange("secondaryYTickText", !SecondaryYTickText, SecondaryYTickText);
3044 }
3045 public boolean isSecondaryYTickText()
3046 {
3047 return sca[2].ticktext;
3048 }
3049 public int bindToSecondaryYScale(int hDisplay, boolean bind)
3050 { int ret = 0;
3051 if (hDisplay < 0 || hDisplay >= n_display) return -1;
3052 if (histo[hDisplay] != null && histo[hDisplay].displayON != 0 && histo[hDisplay].lockFlag == 0)
3053 {
3054 histo[hDisplay].bindSecondaryY = bind;
3055 ret = bind ? 1 : 0;
3056 prepareDraw();
3057 }
3058 else ret = -1;
3059 return ret;
3060 }
3061 public int bindToSecondaryYScale(int hDisplay)
3062 {
3063 return bindToSecondaryYScale(hDisplay, true);
3064 }
3065 public void setColorFilled(boolean colorFilled)
3066 {
3067 if (this.colorFilled == colorFilled) return;
3068 this.colorFilled = colorFilled;
3069 if (randomData == true)
3070 {
3071 rescaleFlag = 2;
3072 prepareDraw();
3073 }
3074 firePropertyChange("colorFilled", !this.colorFilled, colorFilled);
3075 }
3076 public boolean isColorFilled()
3077 {
3078 return this.colorFilled;
3079 }
3080 public void setLeftTimeLabel(boolean leftTimeLabel)
3081 {
3082 if (aFrame.leftTimeLabel == leftTimeLabel) return;
3083 aFrame.leftTimeLabel = leftTimeLabel;
3084 if (sca[0].xtime != 0)
3085 {
3086 sca[0].scaleToGrid();
3087
3088 }
3089 firePropertyChange("leftTimeLabel", !leftTimeLabel, leftTimeLabel);
3090 }
3091 public boolean isLeftTimeLabel()
3092 {
3093 return aFrame.leftTimeLabel;
3094 }
3095 public void setAbsTimeDisplay(boolean absTimeDisplay)
3096 {
3097 if (aFrame.absTimeDisplay == absTimeDisplay) return;
3098 aFrame.absTimeDisplay = absTimeDisplay;
3099 if (sca[0].xtime != 0)
3100 {
3101 sca[0].scaleToGrid();
3102 }
3103 firePropertyChange("absTimeDisplay", !absTimeDisplay, absTimeDisplay);
3104 }
3105 public boolean isAbsTimeDisplay()
3106 {
3107 return aFrame.absTimeDisplay;
3108 }
3109 public void setLeftYLabel(boolean leftYLabel)
3110 {
3111 if (sca[1].leftBottLabel == leftYLabel) return;
3112 sca[1].leftBottLabel = leftYLabel;
3113 setTickRectangle(1);
3114 if (aFrame.drawFlag == false || randomData == false) return;
3115 this.repaint();
3116 firePropertyChange("leftYLabel", !leftYLabel, leftYLabel);
3117 }
3118 public boolean isLeftYLabel()
3119 {
3120 return sca[1].leftBottLabel;
3121 }
3122 public void setBottomXLabel(boolean bottomXLabel)
3123 {
3124 if (sca[0].leftBottLabel == bottomXLabel) return;
3125 sca[0].leftBottLabel = bottomXLabel;
3126 setTickRectangle(0);
3127 firePropertyChange("bottomXLabel", !sca[0].leftBottLabel, sca[0].leftBottLabel);
3128 if (aFrame.drawFlag == false || randomData == false) return;
3129 this.repaint();
3130 }
3131 public boolean isBottomXLabel()
3132 {
3133 return sca[0].leftBottLabel;
3134 }
3135 public void setBarlineColorFilled(int barlineColorFilled)
3136 {
3137 if (this.barlineColorFilled == barlineColorFilled || this.barlineColorFilled * barlineColorFilled > 0 ) return;
3138 int oldValue = this.barlineColorFilled;
3139 this.barlineColorFilled = barlineColorFilled;
3140 if (aFrame.drawFlag) repaintHisto();
3141 firePropertyChange("barlineColorFilled", oldValue, this.barlineColorFilled);
3142 }
3143 public int getBarlineColorFilled()
3144 {
3145 return this.barlineColorFilled;
3146 }
3147 public void setPrintTextStickyAttribute(int printTextStickyAttribute)
3148 {
3149 if (this.printTextStickyAttribute == printTextStickyAttribute) return;
3150 int oldValue = this.printTextStickyAttribute;
3151 this.printTextStickyAttribute = printTextStickyAttribute;
3152 firePropertyChange("printTextStickyAttribute", oldValue, this.printTextStickyAttribute);
3153 }
3154 public int getPrintTextStickyAttribute()
3155 {
3156 return this.printTextStickyAttribute;
3157 }
3158 public void setPrintTextLocation(int printTextLocation)
3159 {
3160 if (this.printTextLocation == printTextLocation) return;
3161 int oldValue = this.printTextLocation;
3162 this.printTextLocation = printTextLocation;
3163 firePropertyChange("printTextLocation", oldValue, this.printTextLocation);
3164 }
3165 public int getPrintTextLocation()
3166 {
3167 return this.printTextLocation;
3168 }
3169 public void setPrintTextRotation(int printTextRotation)
3170 {
3171 if (this.printTextRotation == printTextRotation) return;
3172 int oldValue = this.printTextRotation;
3173 this.printTextRotation = printTextRotation;
3174 firePropertyChange("printTextRotation", oldValue, this.printTextRotation);
3175 }
3176 public int getPrintTextRotation()
3177 {
3178 return this.printTextRotation;
3179 }
3180 public void setXlabelRotation(int xlabelRotation)
3181 {
3182 xlabelRotation = xlabelRotation % 360;
3183 if (this.xlabelRotation == xlabelRotation) return;
3184 int oldValue = this.xlabelRotation;
3185 this.xlabelRotation = xlabelRotation;
3186 if (xlabelRotation == 90 || xlabelRotation == -270)
3187 xlabelAxis = 1;
3188 else if (xlabelRotation == 180 || xlabelRotation == -180)
3189 xlabelAxis = 2;
3190 else if (xlabelRotation == 270 || xlabelRotation == -90)
3191 xlabelAxis = 3;
3192 else
3193 xlabelAxis = 0;
3194 xlabelRotateGrad = xlabelRotation * Math.PI / 180;
3195 xlabelcos = Math.cos(xlabelRotateGrad);
3196 xlabelsin = Math.sin(xlabelRotateGrad);
3197 if (xlabelsin > 0)
3198 xlabelQudrant = xlabelcos < 0 ? 2 : 1;
3199 else
3200 xlabelQudrant = xlabelcos < 0 ? 3 : 4;
3201 firePropertyChange("xLabelRotation", oldValue, this.xlabelRotation);
3202 }
3203 public int getXlabelRotation()
3204 {
3205 return this.xlabelRotation;
3206 }
3207 public int leadingEdge(int LeadingEdgeMode, int hDisplay)
3208 {
3209 int num, ende;
3210 if (LeadingEdgeMode < 0 || LeadingEdgeMode > 3) LeadingEdgeMode = 0;
3211 if (hDisplay < 0 || hDisplay >= n_display)
3212 {
3213 num = 0;
3214 ende = n_display - 1;
3215 }
3216 else
3217 ende = num = n_display;
3218 for (; num <= ende; num++)
3219 {
3220 if (histo[hDisplay] == null) continue;
3221 histo[num].edgeMode = LeadingEdgeMode;
3222 }
3223 return LeadingEdgeMode;
3224 }
3225 public int leadingEdge(int hDisplay)
3226 {
3227 if (hDisplay < 0 || hDisplay >= n_display)
3228 return LeadingEdgeMode;
3229 else if (histo[hDisplay] == null)
3230 return 0;
3231 else
3232 return histo[hDisplay].edgeMode;
3233 }
3234 public void setLeadingEdgeColor(java.awt.Color LeadingEdgeColor)
3235 {
3236 if (this.LeadingEdgeColor == LeadingEdgeColor) return;
3237 Color oldValue = this.LeadingEdgeColor;
3238 this.LeadingEdgeColor = LeadingEdgeColor;
3239 firePropertyChange("leadingEdgeColor", oldValue, this.LeadingEdgeColor);
3240 }
3241 public java.awt.Color getLeadingEdgeColor()
3242 {
3243 return this.LeadingEdgeColor;
3244 }
3245 public void setLeadingEdgeGapSize(int LeadingEdgeGapSize)
3246 {
3247 if (this.LeadingEdgeGapSize == LeadingEdgeGapSize) return;
3248 int oldValue = this.LeadingEdgeGapSize;
3249 this.LeadingEdgeGapSize = LeadingEdgeGapSize;
3250 firePropertyChange("leadingEdgeGapSize", oldValue, this.LeadingEdgeGapSize);
3251 }
3252 public int getLeadingEdgeGapSize()
3253 {
3254 return this.LeadingEdgeGapSize;
3255 }
3256 public void setLeadingEdgeMotion(int LeadingEdgeMotion)
3257 {
3258 if (this.LeadingEdgeMotion == LeadingEdgeMotion) return;
3259 int oldValue = this.LeadingEdgeMotion;
3260 this.LeadingEdgeMotion = LeadingEdgeMotion;
3261 if (aFrame.drawFlag) repaintHisto();
3262 firePropertyChange("leadingEdgeMotion", oldValue, this.LeadingEdgeMotion);
3263 }
3264 public int getLeadingEdgeMotion()
3265 {
3266 return this.LeadingEdgeMotion;
3267 }
3268 public void setLeadingEdgeMode(int LeadingEdgeMode)
3269 {
3270 if (LeadingEdgeMode < 0 || LeadingEdgeMode > 3) LeadingEdgeMode = 0;
3271 if (this.LeadingEdgeMode == LeadingEdgeMode) return;
3272 int oldValue = this.LeadingEdgeMode;
3273 this.LeadingEdgeMode = LeadingEdgeMode;
3274 if (aFrame.drawFlag) repaintHisto();
3275 firePropertyChange("leadingEdgeMode", oldValue, this.LeadingEdgeMode);
3276 }
3277 public int getLeadingEdgeMode()
3278 {
3279 return this.LeadingEdgeMode;
3280 }
3281 public void setLeadingEdgeWidth(int LeadingEdgeWidth)
3282 {
3283 if (LeadingEdgeWidth < 0) LeadingEdgeWidth = 1;
3284 if (this.LeadingEdgeWidth == LeadingEdgeWidth) return;
3285 int oldValue = this.LeadingEdgeWidth;
3286 this.LeadingEdgeWidth = LeadingEdgeWidth;
3287 firePropertyChange("leadingEdgeWidth", oldValue, this.LeadingEdgeWidth);
3288 }
3289 public int getLeadingEdgeWidth()
3290 {
3291 return this.LeadingEdgeWidth;
3292 }
3293 public void setLeadingEdgeStyle(int LeadingEdgeStyle)
3294 {
3295 if (LeadingEdgeStyle < AcopConst.PS_SOLID) LeadingEdgeStyle = AcopConst.PS_SOLID;
3296 if (this.LeadingEdgeStyle == LeadingEdgeStyle) return;
3297 int oldValue = this.LeadingEdgeStyle;
3298 this.LeadingEdgeStyle = LeadingEdgeStyle;
3299 firePropertyChange("leadingEdgeStyle", oldValue, this.LeadingEdgeStyle);
3300 }
3301 public int getLeadingEdgeStyle()
3302 {
3303 return this.LeadingEdgeStyle;
3304 }
3305 public void setLeadingEdgeXExtent(double LeadingEdgeXExtent)
3306 {
3307 if (Math.abs(this.LeadingEdgeXExtent - LeadingEdgeXExtent) < AcopConst.zero_check) return;
3308 double oldValue = this.LeadingEdgeXExtent;
3309 this.LeadingEdgeXExtent = LeadingEdgeXExtent;
3310 firePropertyChange("leadingEdgeXExtent", oldValue, this.LeadingEdgeXExtent);
3311 }
3312 public double getLeadingEdgeXExtent()
3313 {
3314 return this.LeadingEdgeXExtent;
3315 }
3316 public void setLeadingEdgeYExtent(double LeadingEdgeYExtent)
3317 {
3318 if (Math.abs(this.LeadingEdgeYExtent - LeadingEdgeYExtent) < AcopConst.zero_check) return;
3319 double oldValue = this.LeadingEdgeYExtent;
3320 this.LeadingEdgeYExtent = LeadingEdgeYExtent;
3321 firePropertyChange("leadingEdgeYExtent", oldValue, this.LeadingEdgeYExtent);
3322 }
3323 public double getLeadingEdgeYExtent()
3324 {
3325 return this.LeadingEdgeYExtent;
3326 }
3327
3328
3329
3330
3331
3332
3333 public void autoScale(boolean xmx, boolean xmn, boolean ymx, boolean ymn)
3334 {
3335 autoScale(xmx, xmn, ymx, ymn, -1);
3336 }
3337 public void autoScale(boolean xmx, boolean xmn, boolean ymx, boolean ymn, int hIndex)
3338 {
3339 double autotmp, checkXmin, checkXmax, xMax, xMin;
3340 double[] yMin = new double[2];
3341 double[] yMax = new double[2];
3342 double[] autotmpY = new double[2];
3343 int [] yFlags = new int[2];
3344 int [] autoflgY = new int[2];
3345 int i, j, autoflg, start, stop, yIndex;
3346 if (!xmx && !xmn && !ymx && !ymn) return;
3347 if (histo[m_histstart] == null) return;
3348 if (hIndex < -1 || hIndex >= n_display) return;
3349 if (hIndex != -1 && histo[hIndex] == null) return;
3350 if (hIndex != -1)
3351 {
3352 start = hIndex;
3353 stop = hIndex + 1;
3354
3355 }
3356 else
3357 {
3358 start = 0;
3359 stop = n_display;
3360 }
3361 xMax = sca[0].usermax;
3362 if (xmx) for (i = start, autoflg = 0; i < stop && histo[i] != null; i++)
3363 {
3364 if (i != m_histstart && histo[i].displayON == 0) continue;
3365 autotmp = histo[i].maxOf(histo[i].x);
3366 if (autoflg == 0)
3367 {
3368 xMax = autotmp;
3369 autoflg = 1;
3370 }
3371 else if (xMax < autotmp) xMax = autotmp;
3372 }
3373 xMin = sca[0].usermin;
3374 if (xmn) for (i = start, autoflg = 0; i < stop && histo[i] != null; i++)
3375 {
3376 if (i != m_histstart && histo[i].displayON == 0) continue;
3377 autotmp = histo[i].minOf(histo[i].x);
3378 if (autoflg == 0)
3379 {
3380 xMin = autotmp;
3381 autoflg = 1;
3382 }
3383 else if (xMin > autotmp) xMin = autotmp;
3384 }
3385 for (i=0;i<2;i++)
3386 {
3387 yFlags[i] = autoflgY[i] = 0;
3388 yMax[i] = sca[i+1].usermax;
3389 }
3390
3391 if (ymx) for (i = start; i < stop && histo[i] != null; i++)
3392 {
3393 if (i != m_histstart && histo[i].displayON == 0) continue;
3394 yIndex = histo[i].bindSecondaryY ? 1 : 0;
3395 yFlags[yIndex]++;
3396 if (xmx && xmn)
3397 autotmpY[yIndex] = histo[i].maxOf(histo[i].y);
3398 else
3399 {
3400 checkXmin = sca[0].getMin();
3401 checkXmax = sca[0].getMax();
3402 autotmpY[yIndex] = -1.7E308;
3403 for (j = 0; j < histo[i].npoints; j++)
3404 {
3405 if (histo[i].disable[j] != 0) continue;
3406 if (xmx == false && histo[i].x[j] > checkXmax) continue;
3407 if (xmn == false && histo[i].x[j] < checkXmin) continue;
3408 if (histo[i].y[j] > autotmpY[yIndex]) autotmpY[yIndex] = histo[i].y[j];
3409 }
3410 }
3411 if (autoflgY[yIndex] == 0)
3412 {
3413 yMax[yIndex] = autotmpY[yIndex];
3414 autoflgY[yIndex] = 1;
3415 }
3416 else if (yMax[yIndex] < autotmpY[yIndex]) yMax[yIndex] = autotmpY[yIndex];
3417 }
3418 for (i=0;i<2;i++)
3419 {
3420 autoflgY[i] = 0;
3421 yMin[i] = sca[i+1].usermin;
3422 }
3423
3424 if (ymn)
3425 for (i = start; i < stop && histo[i] != null; i++)
3426 {
3427 if (i != m_histstart && histo[i].displayON == 0) continue;
3428 yIndex = histo[i].bindSecondaryY ? 1 : 0;
3429 yFlags[yIndex]++;
3430 if (xmx && xmn)
3431 autotmpY[yIndex] = histo[i].minOf(histo[i].y);
3432 else
3433 {
3434 checkXmin = sca[0].getMin();
3435 checkXmax = sca[0].getMax();
3436 autotmpY[yIndex] = 1.7E308;
3437 for (j = 0; j < histo[i].npoints; j++)
3438 {
3439 if (histo[i].disable[j] != 0) continue;
3440 if (xmx == false && histo[i].x[j] > checkXmax) continue;
3441 if (xmn == false && histo[i].x[j] < checkXmin) continue;
3442 if (histo[i].y[j] < autotmpY[yIndex])
3443 if (sca[yIndex+1].log == 0 || histo[i].y[j] > 1.0e-30) autotmpY[yIndex] = histo[i].y[j];
3444 }
3445 }
3446 if (autoflgY[yIndex] == 0)
3447 {
3448 yMin[yIndex] = autotmpY[yIndex];
3449 autoflgY[yIndex] = 1;
3450 }
3451 else if (yMin[yIndex] > autotmpY[yIndex]) yMin[yIndex] = autotmpY[yIndex];
3452 }
3453 if (xMax <= xMin + AcopConst.zero_check)
3454 {
3455 autotmp = Math.abs(xMin);
3456 if (autotmp < AcopConst.zero_check)
3457 {
3458 xMin -= 5;
3459 xMax = xMin + 10;
3460 }
3461 else
3462 {
3463 xMin -= (0.5 * autotmp);
3464 xMax = xMin + autotmp;
3465 }
3466 }
3467 for (i = 0; i < 2; i++)
3468 {
3469 if ( yFlags[i] == 0 ) continue;
3470 if (yMax[i] <= yMin[i] + AcopConst.zero_check)
3471 {
3472 if ( !ymn && ymx )
3473 {
3474 autotmp = Math.abs(yMin[i]);
3475 if (autotmp < AcopConst.zero_check) yMax[i] = yMin[i] + 10;
3476 else yMax[i] = yMin[i] + Math.abs(yMin[i]);
3477 }
3478 else if ( ymn && !ymx )
3479 {
3480 autotmp = Math.abs(yMax[i]);
3481 if (autotmp < AcopConst.zero_check) yMin[i] = yMax[i] - 10;
3482 else yMin[i] = yMax[i] - Math.abs(yMax[i]);
3483 }
3484 else
3485 {
3486 autotmp = Math.abs(yMin[i]);
3487 if (autotmp < AcopConst.zero_check)
3488 {
3489 yMin[i] -= 5;
3490 yMax[i] = yMin[i] + 10;
3491 }
3492 else
3493 {
3494 yMin[i] -= (0.5 * autotmp);
3495 yMax[i] = yMin[i] + autotmp;
3496 }
3497 }
3498 }
3499 }
3500 if (xmx || xmn) sca[0].setUserscale(xMin, xMax);
3501 if (ymx || ymn) for (i=0; i<2; i++) if (yFlags[i] != 0) sca[i+1].setUserscale(yMin[i], yMax[i]);
3502
3503 rescaleFlag = 2;
3504 rescaleTextFlag = AcopConst.NEW_ZOOM_WINDOW;
3505 prepareDraw();
3506 }
3507 protected void onRButtonDown(Point point)
3508 {
3509 if (aFrame.drawFlag == false && textFlag == false) return;
3510 if (aFrame.drawFlag && histo[m_histstart].dismode == AcopConst.mode_textbox) return;
3511 if ((isZoomed || (wrapAround && sca[0].log == 0)) && histRoundRect.contains(point))
3512 {
3513 movie = true;
3514 moviepoint = point;
3515 saveBestFlag = (sca[0].bestScale ? 1 : 0) + (sca[1].bestScale ? 2 : 0);
3516 sca[0].bestScale = false;
3517 sca[1].bestScale = false;
3518 }
3519 if (isZoomed) rButtonPoint = point;
3520 }
3521 private void doBufferedZoom()
3522 {
3523 int i;
3524 if ((zooming & 0x4) != 0 && zoomIndex > 0 )
3525 {
3526 zoomIndex--;
3527 for (i = 0; i < 3; i++)
3528 {
3529 sca[i].setDispscale(bufferedMin[zoomIndex][i], bufferedMax[zoomIndex][i]);
3530 if (sca[i].log != 0) sca[i].setDispscale(Math.pow(10.0, sca[i].min), Math.pow(10.0, sca[i].max));
3531 }
3532 bufferedZoomRatio = "Z" + zoomIndex;
3533 if (zoomIndex != 0) sca[0].scaleToGrid();
3534 }
3535 if (m_marker == 2) setmarkerflag(2);
3536 rescaleFlag = zoomIndex == 0 ? 2 : 1;
3537 rescaleTextFlag = AcopConst.NEW_ZOOM_WINDOW;
3538 prepareDraw();
3539 if (zoomIndex == 0) isZoomed = false;
3540 notifyAcop(AcopEvent.ACOP_MOUSE_ZOOM_EVENT);
3541 }
3542 protected void onRButtonUp(Point point)
3543 {
3544 if (movie == false)
3545 {
3546 if (!isZoomed || (zooming & 0x4) == 0 || rButtonPoint != point) return;
3547 doBufferedZoom();
3548 return;
3549 }
3550 movie = false;
3551 if (saveBestFlag != 0)
3552 {
3553 if ((saveBestFlag & 0x1) != 0) sca[0].bestScale = true;
3554 if ((saveBestFlag & 0x2) != 0) sca[1].bestScale = true;
3555 }
3556 }
3557 protected void onMouseMove(Point point)
3558 {
3559 double mx, my, x, y, tx, ty, xcheckmin, xcheckmax;
3560 boolean reScale;
3561 int i;
3562 double[] low = new double[3];
3563 double[] high = new double[3];
3564 reScale = true;
3565
3566 for (i = 0; i < 3; i++)
3567 {
3568 if (i == 2 && sca[i].OnFlag == false) continue;
3569 low[i] = sca[i].getMin();
3570 high[i] = sca[i].getMax();
3571
3572
3573
3574
3575 }
3576 if (wrapAround == false || sca[0].log != 0)
3577 {
3578 xcheckmin = sca[0].usermin;
3579 xcheckmax = sca[0].usermax;
3580 }
3581 else
3582 {
3583 xcheckmin = wrapxmin - sca[0].dispSize - AcopConst.zero_check;
3584 xcheckmax = wrapxmax + sca[0].dispSize + AcopConst.zero_check;
3585 }
3586 if ((point.x < moviepoint.x && low[0] > xcheckmin) || (point.x > moviepoint.x && high[0] < xcheckmax)
3587 || (point.y > moviepoint.y && low[1] > sca[1].usermin)
3588 || (point.y < moviepoint.y && high[1] < sca[1].usermax))
3589 {
3590 for (i = 0; i < 3; i++)
3591 {
3592 if (i == 2 && sca[i].OnFlag == false) continue;
3593 if (sca[i].log != 0) sca[i].setDispscale(low[i], high[i]);
3594 }
3595 x = sca[0].dispSize * moviePercent;
3596 if (point.x < moviepoint.x)
3597 {
3598 if (sca[0].log != 0)
3599 {
3600 if ((++xCnt < movieLogCnt) || (sca[0].usermin < AcopConst.zero_check && sca[0].min < 0.1)
3601 || sca[0].min / 10 < sca[0].usermin)
3602 reScale = false;
3603 else
3604 {
3605 sca[0].setDispscale(sca[0].min / 10, sca[0].max / 10);
3606 xCnt = 0;
3607 }
3608 }
3609 else
3610 {
3611 if (sca[0].min - x < xcheckmin) x = sca[0].min - xcheckmin;
3612 sca[0].setDispscale(sca[0].min - x, sca[0].max - x);
3613 if (wrapAround && sca[0].max <= wrapxmin)
3614 sca[0].setDispscale(wrapxmax - sca[0].dispSize, wrapxmax);
3615 }
3616 }
3617 else if (point.x > moviepoint.x)
3618 {
3619 if (sca[0].log != 0)
3620 {
3621 if ((--xCnt <= -movieLogCnt) && sca[0].max * 10 <= sca[0].usermax)
3622 {
3623 sca[0].setDispscale(sca[0].min * 10, sca[0].max * 10);
3624 xCnt = 0;
3625 }
3626 else
3627 reScale = false;
3628 }
3629 else
3630 {
3631 if (sca[0].max + x > xcheckmax) x = xcheckmax - sca[0].max;
3632 sca[0].setDispscale(sca[0].min + x, sca[0].max + x);
3633 if (wrapAround && sca[0].min >= wrapxmax)
3634 sca[0].setDispscale(wrapxmin, wrapxmin + sca[0].dispSize);
3635 }
3636 }
3637 for (i = 1; i < 3; i++)
3638 {
3639 if (i == 2 && sca[i].OnFlag == false) continue;
3640 y = sca[i].dispSize * moviePercent;
3641 if (point.y > moviepoint.y)
3642 {
3643 if (sca[i].log != 0)
3644 {
3645 if ((++yCnt < movieLogCnt) || (sca[i].usermin < AcopConst.zero_check && sca[i].min < 0.1)
3646 || sca[i].min / 10 < sca[i].usermin)
3647 reScale = false;
3648 else
3649 {
3650 sca[i].setDispscale(sca[i].min / 10, sca[i].max / 10);
3651 yCnt = 0;
3652 }
3653 }
3654 else
3655 {
3656 if (sca[i].min - y < sca[i].usermin) y = sca[i].min - sca[i].usermin;
3657 sca[i].setDispscale(sca[i].min - y, sca[i].max - y);
3658 }
3659 }
3660 else if (point.y < moviepoint.y)
3661 {
3662 if (sca[i].log != 0)
3663 {
3664 if ((--yCnt <= -movieLogCnt) && sca[i].max * 10 <= sca[i].usermax)
3665 {
3666 sca[i].setDispscale(sca[i].min * 10, sca[i].max * 10);
3667 yCnt = 0;
3668 }
3669 else
3670 reScale = false;
3671 }
3672 else
3673 {
3674 if (sca[i].max + y > sca[i].usermax) y = sca[i].usermax - sca[i].max;
3675 sca[i].setDispscale(sca[i].min + y, sca[i].max + y);
3676 }
3677 }
3678 }
3679 if (reScale == true)
3680 {
3681 sca[0].scaleToGrid();
3682 if (m_marker == 2) setmarkerflag(2);
3683 rescaleFlag = 1;
3684 rescaleTextFlag = AcopConst.NEW_MOVE_WINDOW;
3685 prepareDraw();
3686
3687 if (isZoomed && zooming != 0x4) notifyAcop(AcopEvent.ACOP_MOUSE_ZOOM_EVENT);
3688
3689 }
3690 else
3691 for (i = 0; i < 3; i++)
3692 {
3693 if (i == 2 && sca[i].OnFlag == false) continue;
3694 if (sca[i].log != 0)
3695 sca[i].setDispscale(Math.log(sca[i].min) / Math.log(10), Math.log(sca[i].max) / Math.log(10));
3696 }
3697 }
3698 moviepoint = point;
3699 }
3700 protected void onLButtonDown(Point point)
3701 {
3702 if (histo[m_histstart] == null || aFrame.drawFlag == false) return;
3703 if (histo[m_histstart].dismode == AcopConst.mode_textbox) return;
3704 if ((zooming & 0x7) != 0)
3705 {
3706 zoomFlag = true;
3707 zoomRect.setBounds(point.x, point.y, 0, 0);
3708 mStart = point;
3709 mEnd = point;
3710 Graphics2D a = (Graphics2D) getGraphics();
3711 a.setXORMode(Color.darkGray);
3712 BasicGraphicsUtils.drawDashedRect(a, point.x, point.y, 0, 0);
3713 a.setPaintMode();
3714 a.dispose();
3715
3716
3717
3718
3719 }
3720 else
3721 {
3722
3723
3724
3725 }
3726 }
3727 protected void onLButtonUp(Point point)
3728 {
3729 double ftmp, curPos;
3730 double x, y;
3731 double[] storemin = new double[3];
3732 double[] storemax = new double[3];
3733 int i;
3734 if (zoomFlag == false) return;
3735 zoomFlag = false;
3736 if (mEnd.equals(point) == false || mStart == point) return;
3737 Graphics2D a = (Graphics2D) getGraphics();
3738
3739 a.setXORMode(Color.darkGray);
3740 BasicGraphicsUtils.drawDashedRect(a, zoomRect.x, zoomRect.y, zoomRect.width, zoomRect.height);
3741 a.setPaintMode();
3742 a.dispose();
3743
3744 if (zoomRect.x + zoomRect.width < aFrame.histRect.x
3745 || zoomRect.x > aFrame.histRect.x + aFrame.histRect.width
3746 || zoomRect.y + zoomRect.height < aFrame.histRect.y
3747 || zoomRect.y > aFrame.histRect.y + aFrame.histRect.height) return;
3748
3749 if (zoomRect.width > 2 && zoomRect.height > 2
3750 && (zoomRect.width < aFrame.histRect.width || zoomRect.height < aFrame.histRect.height))
3751 {
3752 if ((zooming & 0x4) != 0 && zoomIndex < AcopConst.lengthZoom) for (i = 0; i < 3; i++)
3753 {
3754 storemin[i] = sca[i].min;
3755 storemax[i] = sca[i].max;
3756 }
3757 if ((zooming & 0x1) != 0 || zooming == 0x4)
3758 {
3759 ftmp = (zoomRect.x - aFrame.absxleft) * sca[0].dispSize / aFrame.dxwidth + sca[0].min;
3760 curPos = (zoomRect.x + zoomRect.width - aFrame.absxleft) * sca[0].dispSize / aFrame.dxwidth
3761 + sca[0].min;
3762 if (curPos < sca[0].max) sca[0].setDispscale(sca[0].min, curPos);
3763 if (ftmp > sca[0].min) sca[0].setDispscale(ftmp, sca[0].max);
3764 }
3765 if ((zooming & 0x2) != 0 || zooming == 0x4)
3766
3767 for (i = 1; i < 3; i++)
3768 {
3769 if (i == 2 && sca[i].OnFlag == false) continue;
3770 ftmp = (1. - (double) (zoomRect.y - aFrame.histRect.y) / aFrame.histRect.height) * sca[i].dispSize
3771 + sca[i].min;
3772 curPos = (1. - (double) (zoomRect.y + zoomRect.height - aFrame.histRect.y) / aFrame.histRect.height)
3773 * sca[i].dispSize + sca[i].min;
3774 if (curPos > sca[i].min) sca[i].setDispscale(curPos, sca[i].max);
3775 if (ftmp < sca[i].max) sca[i].setDispscale(sca[i].min, ftmp);
3776 }
3777 for (i = 0; i < 3; i++)
3778 {
3779 if (sca[i].log != 0)
3780 sca[i].setDispscale(Math.pow(10.0, sca[i].min), Math.pow(10.0, sca[i].max));
3781 else if (sca[i].max < sca[i].min + AcopConst.zero_check)
3782 sca[i].setDispscale(sca[i].min, sca[i].min + AcopConst.zero_check);
3783 }
3784 if (wrapAround && sca[0].log == 0)
3785 {
3786 if (sca[0].min > wrapxmax)
3787 {
3788 ftmp = wrapxmax - wrapxmin;
3789 sca[0].max -= ftmp;
3790 sca[0].min -= ftmp;
3791 }
3792 else if (sca[0].max < wrapxmin)
3793 {
3794 ftmp = wrapxmax - wrapxmin;
3795 sca[0].max += ftmp;
3796 sca[0].min += ftmp;
3797 }
3798 }
3799 isZoomed = true;
3800 sca[0].scaleToGrid();
3801 if (m_marker == 2) setmarkerflag(2);
3802
3803
3804 rescaleFlag = 1;
3805 rescaleTextFlag = AcopConst.NEW_ZOOM_WINDOW;
3806 prepareDraw();
3807 yZoomRatio = "V" + (int) (sca[1].userSize / sca[1].dispSize + 0.5) + ":1";
3808 xZoomRatio = "H" + (int) (sca[0].userSize / sca[0].dispSize + 0.5) + ":1";
3809 if ((zooming & 0x4) != 0 && zoomIndex < AcopConst.lengthZoom)
3810 {
3811 for (i = 0; i < 3; i++)
3812 {
3813 bufferedMin[zoomIndex][i] = storemin[i];
3814 bufferedMax[zoomIndex][i] = storemax[i];
3815 }
3816 zoomIndex++;
3817 bufferedZoomRatio = "Z" + zoomIndex;
3818 }
3819 notifyAcop(AcopEvent.ACOP_MOUSE_ZOOM_EVENT);
3820
3821 }
3822
3823 else if (zoomRect.width >= aFrame.histRect.width && zoomRect.height >= aFrame.histRect.height)
3824 doBufferedZoom();
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844 }
3845
3846
3847
3848
3849
3850
3851 protected void processComponentEvent(ComponentEvent componentEvent)
3852 {
3853
3854 super.processComponentEvent(componentEvent);
3855 switch (componentEvent.getID())
3856 {
3857 case ComponentEvent.COMPONENT_RESIZED:
3858 scaleFrameDraw();
3859 break;
3860 case ComponentEvent.COMPONENT_MOVED:
3861 break;
3862 default:
3863 break;
3864 }
3865 }
3866 protected void processMouseEvent(MouseEvent mouseEvent)
3867 {
3868
3869 super.processMouseEvent(mouseEvent);
3870 mouseX = mouseEvent.getX();
3871 mouseY = mouseEvent.getY();
3872 mousepoint = mouseEvent.getPoint();
3873 switch (mouseEvent.getID())
3874 {
3875 case MouseEvent.MOUSE_ENTERED:
3876 mouseIndex = -1;
3877 notifyAcop(AcopEvent.ACOP_MOUSE_ENTER_EVENT);
3878 break;
3879 case MouseEvent.MOUSE_EXITED:
3880 mouseIndex = -1;
3881 notifyAcop(AcopEvent.ACOP_MOUSE_EXIT_EVENT);
3882 break;
3883 case MouseEvent.MOUSE_PRESSED:
3884 if ((mouseEvent.getModifiers() & MouseEvent.BUTTON1_MASK) != 0)
3885 if (!mouseEvent.isControlDown()) onLButtonDown(mousepoint);
3886 else if ((mouseEvent.getModifiers() & MouseEvent.BUTTON3_MASK) != 0)
3887
3888 onRButtonDown(mousepoint);
3889 notifyAcop(AcopEvent.ACOP_MOUSE_PRESSED_EVENT);
3890 break;
3891 case MouseEvent.MOUSE_RELEASED:
3892 if ((mouseEvent.getModifiers() & MouseEvent.BUTTON1_MASK) != 0)
3893 onLButtonUp(mousepoint);
3894 else if ((mouseEvent.getModifiers() & MouseEvent.BUTTON3_MASK) != 0)
3895
3896 onRButtonUp(mousepoint);
3897 break;
3898 case MouseEvent.MOUSE_CLICKED:
3899 long mouseEventTime = mouseEvent.getWhen();
3900 long mouseButton = mouseEvent.getButton();
3901 boolean doubleClick;
3902 if (mouseButton == previousButton && (mouseEventTime - mousePreviousClickTime < 300))
3903 doubleClick = true;
3904 else
3905 doubleClick = false;
3906 mousePreviousClickTime = mouseEventTime;
3907 previousButton = mouseEvent.getButton();
3908 if (doubleClick)
3909 {
3910 if (histRoundRect.contains(mousepoint) && aFrame.drawFlag)
3911 mouseIndex = histo[m_histstart].getMousePosition(mousepoint, mouseConvert);
3912 else
3913 mouseIndex = -1;
3914 if (isZoomed)
3915 {
3916 rescaleFlag = 2;
3917 if (m_marker == 2) setmarkerflag(2);
3918 rescaleTextFlag = AcopConst.NEW_ZOOM_WINDOW;
3919 prepareDraw();
3920 isZoomed = false;
3921 notifyAcop(AcopEvent.ACOP_MOUSE_ZOOM_EVENT);
3922 }
3923 notifyAcop(AcopEvent.ACOP_MOUSE_DCLICK_EVENT);
3924 }
3925
3926
3927 else if (isZoomed && aFrame.zoomIcon.contains(mousepoint))
3928 doBufferedZoom();
3929
3930
3931
3932
3933
3934
3935
3936
3937 else
3938 {
3939 if (histRoundRect.contains(mousepoint) && aFrame.drawFlag)
3940 mouseIndex = histo[m_histstart].getMousePosition(mousepoint, mouseConvert);
3941 else
3942 mouseIndex = -1;
3943 notifyAcop(AcopEvent.ACOP_MOUSE_CLICK_EVENT);
3944 }
3945 if (mouseEvent.getButton()==MouseEvent.BUTTON3) getPopupManager().showPopup(this,mouseEvent.getX(),mouseEvent.getY());
3946 break;
3947 default:
3948 break;
3949 }
3950 }
3951 protected void processMouseMotionEvent(MouseEvent mouseMotionEvent)
3952 {
3953 int rWidth, rHeight, recX, recY;
3954
3955 super.processMouseMotionEvent(mouseMotionEvent);
3956 mouseX = mouseMotionEvent.getX();
3957 mouseY = mouseMotionEvent.getY();
3958 mousepoint = mouseMotionEvent.getPoint();
3959 switch (mouseMotionEvent.getID())
3960 {
3961 case MouseEvent.MOUSE_MOVED:
3962 if (aFrame.drawFlag && histRoundRect.contains(mousepoint))
3963 {
3964 if (m_cursorMarkerMode != 0 && cursorStay == 0) drawCursorMarker(null, mousepoint);
3965 mMovePoint.x = mousepoint.x;
3966 mMovePoint.y = mousepoint.y;
3967 mouseIndex = histo[m_histstart].getMousePosition(mousepoint, mouseConvert);
3968 notifyAcop(AcopEvent.ACOP_MOUSE_MOVE_EVENT);
3969 }
3970
3971
3972 break;
3973 case MouseEvent.MOUSE_DRAGGED:
3974 if (zoomFlag)
3975 {
3976 Graphics2D a = (Graphics2D) getGraphics();
3977 a.setXORMode(Color.darkGray);
3978 BasicGraphicsUtils.drawDashedRect(a, zoomRect.x, zoomRect.y, zoomRect.width, zoomRect.height);
3979 mEnd = mousepoint;
3980 rWidth = Math.abs(mEnd.x - mStart.x);
3981 rHeight = Math.abs(mEnd.y - mStart.y);
3982 recX = Math.min(mEnd.x, mStart.x);
3983 recY = Math.min(mEnd.y, mStart.y);
3984 zoomRect.setBounds(recX, recY, rWidth, rHeight);
3985 BasicGraphicsUtils.drawDashedRect(a, recX, recY, rWidth, rHeight);
3986 a.setPaintMode();
3987 a.dispose();
3988 }
3989 else if (movie)
3990 onMouseMove(mousepoint);
3991 else if (aFrame.drawFlag && m_cursorMarkerMode != 0 && cursorStay == 0
3992 && histRoundRect.contains(mousepoint))
3993 {
3994 drawCursorMarker(null, mousepoint);
3995 mMovePoint.x = mousepoint.x;
3996 mMovePoint.y = mousepoint.y;
3997 }
3998 break;
3999 default:
4000 break;
4001 }
4002 }
4003 private void drawtext(java.awt.Graphics2D g2d)
4004 {
4005 if (textFlag == false) return;
4006 Rectangle Cliprect = g2d.getClipBounds();
4007 if (Cliprect != null)
4008 {
4009 if (Cliprect.intersects(histRoundRect) == false) return;
4010 }
4011 g2d.clipRect(histRoundRect.x, histRoundRect.y, histRoundRect.width, histRoundRect.height);
4012 g2d.translate(aFrame.histRect.x, aFrame.histRect.y);
4013 for (int i = 0; i < n_text; i++)
4014 {
4015 if (ptext[i] == null) break;
4016 ptext[i].printUserText(g2d);
4017 }
4018 g2d.translate(-aFrame.histRect.x, -aFrame.histRect.y);
4019 g2d.setClip(Cliprect);
4020 }
4021 private void drawhist(java.awt.Graphics2D g2d)
4022 {
4023 if (aFrame.drawFlag == false && textFlag == false) return;
4024 Rectangle Cliprect = g2d.getClipBounds();
4025 if (Cliprect != null)
4026 {
4027 if (Cliprect.intersects(histRoundRect) == false) return;
4028 }
4029 g2d.clipRect(histRoundRect.x, histRoundRect.y, histRoundRect.width, histRoundRect.height);
4030 g2d.translate(aFrame.histRect.x, aFrame.histRect.y);
4031 for (int i = 0; i < 2; i++)
4032 sca[i].drawGrid(g2d);
4033 for (int i = 0; i < 2; i++)
4034 axis[i].drawAxis(g2d);
4035 if (aFrame.drawFlag) for (int i = 0; i < n_display; i++)
4036 {
4037 if (histo[i] == null) break;
4038 histo[i].drawhist(g2d);
4039 }
4040 if (aFrame.drawFlag && m_cursorMarkerMode != 0 && histRoundRect.contains(mMovePoint))
4041 {
4042
4043 g2d.setColor(Color.black);
4044 if ( cursorStay > 0 )
4045 {
4046 mMovePoint.x = sca[0].getScreenPosition(cursorXposition);
4047 mMovePoint.y = sca[1].getScreenPosition(cursorYposition);
4048 }
4049 drawCursorMarker(g2d, mMovePoint);
4050 }
4051 else
4052 cursorMarkerFlag = 0;
4053 g2d.translate(-aFrame.histRect.x, -aFrame.histRect.y);
4054 g2d.setClip(Cliprect);
4055 }
4056 private void captionPaint(java.awt.Graphics2D g2d)
4057 {
4058 FontMetrics fMetrix;
4059 int xPosition, len, hei;
4060 Rectangle Cliprect = g2d.getClipBounds();
4061 if ( caption == null ) return;
4062 if (Cliprect != null)
4063 {
4064 if (Cliprect.intersects(titleRect) == false) return;
4065 }
4066 if (captionFont == null || captionChanged == true || randomData == true)
4067 {
4068 captionFont = new Font(g2d.getFont().getAttributes());
4069 captionChanged = false;
4070 }
4071 Font tmpFont = g2d.getFont();
4072 AffineTransform transform = g2d.getTransform();
4073 g2d.clipRect(titleRect.x, titleRect.y, titleRect.width + 1, titleRect.height + 1);
4074 g2d.setFont(captionFont);
4075 fMetrix = g2d.getFontMetrics();
4076 len = fMetrix.stringWidth(caption);
4077 hei = (fMetrix.getDescent() + fMetrix.getAscent()) / 2;
4078 if (captionPosition == 1)
4079 xPosition = (titleRect.width - len) / 2;
4080 else if (captionPosition < 1)
4081 xPosition = 2;
4082 else
4083 xPosition = titleRect.width - len - 2;
4084 g2d.setColor(aFrame.frameForeColor);
4085 g2d.drawString(caption, xPosition, sca[0].leftBottom ? (fTop - 4) : (fTop - 4 - hei * 2));
4086 g2d.setTransform(transform);
4087 g2d.setFont(tmpFont);
4088 g2d.setClip(Cliprect);
4089 }
4090 private void backgroundPaint(java.awt.Graphics2D g2d, Rectangle Cliprect, Rectangle acopRect)
4091 {
4092 int i;
4093 if (nBackRegions == 0)
4094 {
4095 g2d.setColor(getBackground());
4096
4097 if (Cliprect == null)
4098 g2d.fillRect(0,0,acopRect.width, acopRect.height);
4099
4100 else
4101 g2d.fillRect(Cliprect.x, Cliprect.y, Cliprect.width, Cliprect.height);
4102
4103 return;
4104 }
4105 g2d.setColor(getBackground());
4106
4107 if (false)
4108 {
4109 if (Cliprect == null || Cliprect.intersects(titleRect) == true)
4110 g2d.fillRect(titleRect.x, titleRect.y, titleRect.width, titleRect.height);
4111
4112 if (Cliprect == null || Cliprect.intersects(xRect) == true)
4113 g2d.fillRect(xRect.x, xRect.y, xRect.width, xRect.height);
4114
4115 if (Cliprect == null || Cliprect.intersects(yRect) == true)
4116 g2d.fillRect(yRect.x, yRect.y, yRect.width, yRect.height);
4117
4118 if (Cliprect == null || Cliprect.intersects(yAxisRect) == true)
4119 g2d.fillRect(yAxisRect.x, yAxisRect.y, yAxisRect.width, yAxisRect.height);
4120
4121 }
4122 else
4123 {
4124 if (Cliprect == null)
4125 g2d.fillRect(0,0,acopRect.width, acopRect.height);
4126
4127 else
4128 g2d.fillRect(Cliprect.x, Cliprect.y, Cliprect.width, Cliprect.height);
4129
4130 }
4131 g2d.clipRect(histRoundRect.x, histRoundRect.y, histRoundRect.width, histRoundRect.height);
4132 Rectangle tmpCliprect = g2d.getClipBounds();
4133 for (i = 0; i < nBackRegions; i++)
4134 {
4135 if (backkgroundRegionType[i] == 0) continue;
4136 if (tmpCliprect != null && tmpCliprect.intersects(backRegionRect[i]) == false) continue;
4137 if (backkgroundRegionType[i] == 1)
4138 {
4139 g2d.setColor(backRegionColor[i]);
4140
4141 g2d.fillRect(backRegionRect[i].x, backRegionRect[i].y, backRegionRect[i].width,
4142 backRegionRect[i].height);
4143
4144 }
4145 else if (backkgroundRegionType[i] == 2)
4146 g2d.drawImage(backRegionImage[i], backRegionRect[i].x, backRegionRect[i].y,
4147 backRegionRect[i].width, backRegionRect[i].height, this);
4148 }
4149 g2d.setClip(Cliprect);
4150 }
4151 public void update(java.awt.Graphics a)
4152 {
4153 this.paint(a);
4154 }
4155
4156
4157
4158 @Override
4159 protected void paintComponent(Graphics g) {
4160
4161
4162 java.awt.Graphics2D g2dima = (Graphics2D) g;
4163 Rectangle r = getBounds();
4164
4165 int i;
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176 Rectangle Cliprect = g2dima.getClipBounds();
4177
4178
4179
4180 backgroundPaint(g2dima, Cliprect, r);
4181
4182
4183
4184
4185
4186 g2dima.setColor(aFrame.frameForeColor);
4187 if ( frameBorderOn )
4188 g2dima.drawRect(0, 0, r.width - 1, r.height - 1);
4189 captionPaint(g2dima);
4190 if (changeScaleWidth == 0)
4191 {
4192 scaleframe();
4193
4194
4195
4196
4197 changeScaleWidth = 1;
4198 }
4199 if (Cliprect == null || Cliprect.intersects(histRoundRect) == true)
4200 {
4201 g2dima.setColor(aFrame.frameForeColor);
4202 g2dima.drawRect(histRoundRect.x, histRoundRect.y, histRoundRect.width, histRoundRect.height);
4203 }
4204 drawhist(g2dima);
4205
4206 g2dima.setStroke(stroke);
4207 if (isZoomed && (Cliprect == null || Cliprect.intersects(aFrame.zoomIcon) == true))
4208 {
4209 g2dima.setColor(aFrame.frameForeColor);
4210 g2dima.setFont(aFrame.frameFont);
4211 g2dima.drawRect(aFrame.zoomIcon.x, aFrame.zoomIcon.y, aFrame.zoomIcon.width, aFrame.zoomIcon.height);
4212 g2dima.clipRect(aFrame.zoomIcon.x, aFrame.zoomIcon.y, aFrame.zoomIcon.width, aFrame.zoomIcon.height);
4213 if ((zooming & 0x4) != 0)
4214 g2dima.drawString(bufferedZoomRatio, aFrame.zoomIcon.x + 1, aFrame.zoomIcon.y
4215 + aFrame.zoomIcon.height - 1);
4216 else
4217 {
4218 g2dima.drawString(yZoomRatio, aFrame.zoomIcon.x + 1, aFrame.zoomIcon.y + aFrame.zoomIcon.width / 2);
4219 g2dima.drawString(xZoomRatio, aFrame.zoomIcon.x + 1, aFrame.zoomIcon.y + aFrame.zoomIcon.width - 1);
4220 }
4221 g2dima.setClip(Cliprect);
4222 }
4223 if ((textFlag == true || (aFrame.drawFlag == true && histo[m_histstart].dismode != AcopConst.mode_textbox))
4224 && (fLeft > 0 || fRight > 0 || fBottom > 0 || fTop > 0))
4225 {
4226 for (i = 0; i < 3; i++)
4227 {
4228 if (i == 2 && sca[i].OnFlag == false) continue;
4229 sca[i].drawTicks(g2dima, histo[m_histstart]);
4230 }
4231 }
4232 drawtext(g2dima);
4233 if (zoomFlag && (Cliprect == null || Cliprect.intersects(zoomRect) == true))
4234 {
4235 g2dima.setXORMode(Color.darkGray);
4236 BasicGraphicsUtils.drawDashedRect(g2dima, zoomRect.x, zoomRect.y, zoomRect.width, zoomRect.height);
4237 g2dima.setPaintMode();
4238 }
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256 }
4257
4258
4259
4260
4261 public static void main(String argv[])
4262 {
4263 class DriverFrame extends java.awt.Frame
4264 {
4265 public DriverFrame()
4266 {
4267 addWindowListener(new java.awt.event.WindowAdapter()
4268 {
4269 public void windowClosing(java.awt.event.WindowEvent event)
4270 {
4271 dispose();
4272 System.exit(0);
4273 }
4274 public void windowOpened(java.awt.event.WindowEvent event)
4275 {
4276 int test = 3;
4277 }
4278 });
4279 setLayout(null);
4280 setSize(400, 300);
4281 add(new Acop());
4282 }
4283 }
4284 new DriverFrame().show();
4285 }
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301 public synchronized void addAcopListener(AcopListener l)
4302 {
4303 if (!AcopListeners.contains(l)) AcopListeners.addElement(l);
4304 }
4305 public synchronized void removeAcopListener(AcopListener l)
4306 {
4307 if (AcopListeners.contains(l)) AcopListeners.removeElement(l);
4308 }
4309
4310 protected void notifyAcop(int id)
4311 {
4312
4313 if (id == AcopEvent.ACOP_MOUSE_CLICK_EVENT || id == AcopEvent.ACOP_MOUSE_MOVE_EVENT
4314 || id == AcopEvent.ACOP_MOUSE_ENTER_EVENT || id == AcopEvent.ACOP_MOUSE_EXIT_EVENT
4315 || id == AcopEvent.ACOP_MOUSE_ZOOM_EVENT
4316 || id == AcopEvent.ACOP_MOUSE_DCLICK_EVENT || id == AcopEvent.ACOP_MOUSE_PRESSED_EVENT)
4317 {
4318 AcopEvent evt;
4319 if (id == AcopEvent.ACOP_MOUSE_ZOOM_EVENT)
4320 evt = new AcopEvent(this, id, sca[0].min, sca[1].min, sca[0].max, sca[1].max);
4321 else
4322 evt = new AcopEvent(this, id, mouseIndex, mousepoint.x, mousepoint.y, mouseConvert[0],
4323 mouseConvert[1]);
4324
4325
4326 Vector v;
4327 synchronized (this)
4328 {
4329 v = (Vector) AcopListeners.clone();
4330 }
4331
4332 int cnt = v.size();
4333 for (int i = 0; i < cnt; i++)
4334 {
4335 AcopListener client = (AcopListener) v.elementAt(i);
4336 if (id == AcopEvent.ACOP_MOUSE_CLICK_EVENT)
4337 client.acopMouseClick(evt);
4338 else if (id == AcopEvent.ACOP_MOUSE_DCLICK_EVENT)
4339 client.acopMouseDoubleClick(evt);
4340 else if (id == AcopEvent.ACOP_MOUSE_MOVE_EVENT)
4341 client.acopMouseMove(evt);
4342 else if (id == AcopEvent.ACOP_MOUSE_ENTER_EVENT)
4343 client.acopMouseEnter(evt);
4344 else if (id == AcopEvent.ACOP_MOUSE_EXIT_EVENT)
4345 client.acopMouseExit(evt);
4346 else if (id == AcopEvent.ACOP_MOUSE_ZOOM_EVENT)
4347 client.acopMouseZoom(evt);
4348 else if (id == AcopEvent.ACOP_MOUSE_PRESSED_EVENT)
4349 client.acopMousePressed(evt);
4350
4351 }
4352 }
4353 }
4354 public void notifyAcop(int id, int link, int code)
4355 {
4356
4357 if (id == AcopEvent.ACOP_MOUSE_CLICK_EVENT || id == AcopEvent.ACOP_MOUSE_MOVE_EVENT
4358 || id == AcopEvent.ACOP_MOUSE_ENTER_EVENT || id == AcopEvent.ACOP_MOUSE_EXIT_EVENT
4359 || id == AcopEvent.ACOP_MOUSE_ZOOM_EVENT ||
4360 id == AcopEvent.ACOP_MOUSE_DCLICK_EVENT || id == AcopEvent.ACOP_MOUSE_PRESSED_EVENT)
4361 {
4362 AcopEvent evt;
4363 if (id == AcopEvent.ACOP_MOUSE_ZOOM_EVENT) {
4364 evt = new AcopEvent(this, id, sca[0].min, sca[1].min, sca[0].max, sca[1].max);
4365 } else {
4366 evt = new AcopEvent(this, id, mouseIndex, mousepoint.x, mousepoint.y, mouseConvert[0],
4367 mouseConvert[1]);
4368 }
4369 Vector v;
4370 synchronized (this)
4371 {
4372 v = (Vector) AcopListeners.clone();
4373 }
4374
4375 int cnt = v.size();
4376 for (int i = 0; i < cnt; i++)
4377 {
4378 AcopListener client = (AcopListener) v.elementAt(i);
4379 if (id == AcopEvent.ACOP_MOUSE_CLICK_EVENT)
4380 client.acopMouseClick(evt);
4381 else if (id == AcopEvent.ACOP_MOUSE_DCLICK_EVENT)
4382 client.acopMouseDoubleClick(evt);
4383 else if (id == AcopEvent.ACOP_MOUSE_MOVE_EVENT)
4384 client.acopMouseMove(evt);
4385 else if (id == AcopEvent.ACOP_MOUSE_ENTER_EVENT)
4386 client.acopMouseEnter(evt);
4387 else if (id == AcopEvent.ACOP_MOUSE_EXIT_EVENT)
4388 client.acopMouseExit(evt);
4389 else if (id == AcopEvent.ACOP_MOUSE_ZOOM_EVENT)
4390 client.acopMouseZoom(evt);
4391 else if (id == AcopEvent.ACOP_MOUSE_PRESSED_EVENT)
4392 client.acopMousePressed(evt);
4393
4394 }
4395 }
4396 }
4397 public void setCursorMarkerColor(java.awt.Color cursorMarkerColor)
4398 {
4399
4400
4401 if (m_cursorMarkerColor == cursorMarkerColor) return;
4402 Color oldValue = m_cursorMarkerColor;
4403 m_cursorMarkerColor = cursorMarkerColor;
4404
4405 rev_cursorMarkerColor = new Color(~m_cursorMarkerColor.getRGB() ^ ~backColor.getRGB());
4406 if (m_cursorMarkerMode != 0 && aFrame.drawFlag) repaintHisto();
4407 firePropertyChange("cursorMarkerColor", oldValue, m_cursorMarkerColor);
4408 }
4409 public java.awt.Color getCursorMarkerColor()
4410 {
4411 return m_cursorMarkerColor;
4412 }
4413 public void setCursorMarkerMode(int cursorMarkerMode)
4414 {
4415 cursorMarkerMode = (cursorMarkerMode < 0 || cursorMarkerMode > 3) ? 0 : cursorMarkerMode;
4416 if (m_cursorMarkerMode == cursorMarkerMode) return;
4417 int oldValue = m_cursorMarkerMode;
4418 m_cursorMarkerMode = cursorMarkerMode;
4419 if (m_cursorMarkerMode != 0 && histRoundRect.contains(mMovePoint) == false)
4420 {
4421 mMovePoint.x = histRoundRect.x + histRoundRect.width / 2;
4422 mMovePoint.y = histRoundRect.y + histRoundRect.height / 2;
4423 }
4424 if (aFrame.drawFlag) repaintHisto();
4425 firePropertyChange("cursorMarkerMode", oldValue, m_cursorMarkerMode);
4426 }
4427 public int getCursorMarkerMode()
4428 {
4429 return this.m_cursorMarkerMode;
4430 }
4431 public void setCursorMarkerStyle(int cursorMarkerStyle)
4432 {
4433 if (m_cursorMarkerStyle == cursorMarkerStyle) return;
4434 int oldValue = m_cursorMarkerStyle;
4435 m_cursorMarkerStyle = cursorMarkerStyle;
4436 cursorMarkerStroke = AcopConst.createStroke(m_cursorMarkerWidth, m_cursorMarkerStyle);
4437 if (m_cursorMarkerMode != 0 && aFrame.drawFlag) repaintHisto();
4438 firePropertyChange("cursorMarkerStyle", oldValue, m_cursorMarkerStyle);
4439 }
4440 public int getCursorMarkerStyle()
4441 {
4442 return m_cursorMarkerStyle;
4443 }
4444 public void setCursorMarkerWidth(int cursorMarkerWidth)
4445 {
4446 if (m_cursorMarkerWidth == cursorMarkerWidth) return;
4447 int oldValue = m_cursorMarkerWidth;
4448 m_cursorMarkerWidth = cursorMarkerWidth;
4449 cursorMarkerStroke = AcopConst.createStroke(m_cursorMarkerWidth, m_cursorMarkerStyle);
4450 if (m_cursorMarkerMode != 0 && aFrame.drawFlag) repaintHisto();
4451 firePropertyChange("cursorMarkerWidth", oldValue, m_cursorMarkerWidth);
4452 }
4453 public int getCursorMarkerWidth()
4454 {
4455 return m_cursorMarkerWidth;
4456 }
4457 public void setCursorMarkerXExtent(double cursorMarkerXExtent)
4458 {
4459 if (m_cursorMarkerXExtent == cursorMarkerXExtent) return;
4460 double oldValue = m_cursorMarkerXExtent;
4461 m_cursorMarkerXExtent = cursorMarkerXExtent;
4462 cursorXPercent = -1;
4463 if (m_cursorMarkerMode != 0 && aFrame.drawFlag) repaintHisto();
4464 firePropertyChange("cursorMarkerXExtent", oldValue, m_cursorMarkerXExtent);
4465 }
4466 public double getCursorMarkerXExtent()
4467 {
4468 return m_cursorMarkerXExtent;
4469 }
4470 public void setCursorMarkerYExtent(double cursorMarkerYExtent)
4471 {
4472 if (m_cursorMarkerYExtent == cursorMarkerYExtent) return;
4473 double oldValue = m_cursorMarkerYExtent;
4474 m_cursorMarkerYExtent = cursorMarkerYExtent;
4475 cursorYPercent = -1;
4476 if (m_cursorMarkerMode != 0 && aFrame.drawFlag) repaintHisto();
4477 firePropertyChange("cursorMarkerYExtent", oldValue, m_cursorMarkerYExtent);
4478 }
4479 public double getCursorMarkerYExtent()
4480 {
4481 return m_cursorMarkerYExtent;
4482 }
4483 public void setMarkerColor(java.awt.Color markerColor)
4484 {
4485 if (m_markerColor == markerColor) return;
4486 Color oldValue = m_markerColor;
4487 m_markerColor = markerColor;
4488 if (m_markerMode == 0 && aFrame.drawFlag) repaintHisto();
4489 firePropertyChange("markerColor", oldValue, m_markerColor);
4490 }
4491 public java.awt.Color getMarkerColor()
4492 {
4493 return m_markerColor;
4494 }
4495 public void setMarkerMode(int markerMode)
4496 {
4497 markerMode = (markerMode < 0 || markerMode > 3) ? 0 : markerMode;
4498 if (this.m_markerMode == markerMode) return;
4499 int oldValue = m_markerMode;
4500 m_markerMode = markerMode;
4501 if (aFrame.drawFlag) repaintHisto();
4502 firePropertyChange("markerMode", oldValue, m_markerMode);
4503 }
4504 public int getMarkerMode()
4505 {
4506 return this.m_markerMode;
4507 }
4508 public void setMarkerStyle(int markerStyle)
4509 {
4510 if (this.m_markerStyle == markerStyle) return;
4511 int oldValue = m_markerStyle;
4512 m_markerStyle = markerStyle;
4513 firePropertyChange("markerStyle", oldValue, m_markerStyle);
4514 }
4515 public int getMarkerStyle()
4516 {
4517 return this.m_markerStyle;
4518 }
4519 public void setMarkerWidth(int markerWidth)
4520 {
4521 if (this.m_markerWidth == markerWidth) return;
4522 int oldValue = m_markerWidth;
4523 m_markerWidth = markerWidth;
4524 firePropertyChange("markerWidth", oldValue, m_markerWidth);
4525 }
4526 public int getMarkerWidth()
4527 {
4528 return this.m_markerWidth;
4529 }
4530 public void setMarkerXExtent(double markerXExtent)
4531 {
4532 if (this.m_markerXExtent == markerXExtent) return;
4533 double oldValue = m_markerXExtent;
4534 m_markerXExtent = markerXExtent;
4535 firePropertyChange("markerXExtent", oldValue, m_markerXExtent);
4536 }
4537 public double getMarkerXExtent()
4538 {
4539 return this.m_markerXExtent;
4540 }
4541 public void setMarkerYExtent(double markerYExtent)
4542 {
4543 if (this.m_markerYExtent == markerYExtent) return;
4544 double oldValue = m_markerYExtent;
4545 m_markerYExtent = markerYExtent;
4546 firePropertyChange("markerYExtent", oldValue, m_markerYExtent);
4547 }
4548 public double getMarkerYExtent()
4549 {
4550 return this.m_markerYExtent;
4551 }
4552 public int errorWindow(double XMax, double XMin, double YMax, double YMin)
4553 {
4554 return errorWindow(-1, XMax, XMin, YMax, YMin);
4555 }
4556 public int errorWindow(int hDisplay, double XMax, double XMin, double YMax, double YMin)
4557 {
4558 int i, start, stop, on;
4559
4560 if (hDisplay < -1 || hDisplay > n_display) return -1;
4561 on = 0;
4562 start = hDisplay;
4563 stop = hDisplay + 1;
4564 if (hDisplay == -1)
4565 {
4566 start = 0;
4567 stop = n_display;
4568 e_xmax = XMax;
4569 e_xmin = XMin;
4570 e_ymax = YMax;
4571 e_ymin = YMin;
4572 }
4573 for (i = start; i < stop; i++)
4574 {
4575 if (histo[i] == null) break;
4576 histo[i].err_xmax = XMax;
4577 histo[i].err_xmin = XMin;
4578 histo[i].err_ymax = YMax;
4579 histo[i].err_ymin = YMin;
4580 if (histo[i].errWindowEnable && histo[i].displayON != 0) on = 1;
4581 }
4582 if (aFrame.drawFlag && on != 0) repaintHisto();
4583 return 0;
4584 }
4585 public void setErrorColor(java.awt.Color errorColor)
4586 {
4587 if (m_errorColor == errorColor) return;
4588 Color oldValue = m_errorColor;
4589 m_errorColor = errorColor;
4590 if (histo[lastDisp] != null) histo[lastDisp].errorColor = m_errorColor;
4591 firePropertyChange("errorColor", oldValue, m_errorColor);
4592 }
4593 public java.awt.Color getErrorColor()
4594 {
4595 return m_errorColor;
4596 }
4597 public void setTagColor(java.awt.Color tagColor)
4598 {
4599 if (m_tagColor == tagColor) return;
4600 Color oldValue = m_tagColor;
4601 m_tagColor = tagColor;
4602 for (int i = 0; i < n_display; i++)
4603 {
4604 if (histo[i] == null) break;
4605 histo[i].tagColor = m_tagColor;
4606 }
4607 firePropertyChange("tagColor", oldValue, m_tagColor);
4608 }
4609 public java.awt.Color getTagColor()
4610 {
4611 return m_tagColor;
4612 }
4613 public void setTagging(boolean tagging)
4614 {
4615 if (this.m_tagging == tagging) return;
4616 this.m_tagging = tagging;
4617 if (aFrame.drawFlag) repaintHisto();
4618 firePropertyChange("tagging", !m_tagging, m_tagging);
4619 }
4620 public boolean isTagging()
4621 {
4622 return this.m_tagging;
4623 }
4624 public void clearTags(int hDisplay)
4625 {
4626 int i, j, ok, start, stop;
4627 if (pTagColorArray == null) return;
4628 if (hDisplay >= 0 && hDisplay < n_display)
4629 {
4630 start = n_display;
4631 stop = start + 1;
4632 }
4633 else
4634 {
4635 start = 0;
4636 stop = n_display;
4637 }
4638 ok = 0;
4639 for (j = start; j < stop; j++)
4640 {
4641 if (histo[j] == null) break;
4642 if (histo[j].dismode == AcopConst.mode_histogram
4643 || histo[j].dismode == AcopConst.mode_histogram_rastoring
4644 || histo[j].dismode == AcopConst.mode_dots || histo[j].dismode == AcopConst.mode_rectangle
4645 || histo[j].dismode == AcopConst.mode_circle)
4646 {
4647 ok = 1;
4648 for (i = 0; i < histo[j].npoints; i++)
4649 histo[j].m_tagColorArray[i] = histo[j].vorColor;
4650 }
4651 }
4652 if (ok != 0 && m_tagging && aFrame.drawFlag) repaintHisto();
4653 }
4654 private void repaintHisto()
4655 {
4656 this.repaint(histRoundRect.x, histRoundRect.y, histRoundRect.width, histRoundRect.height);
4657 }
4658
4659 public boolean marker()
4660 {
4661 return m_marker != 0 ? true : false;
4662 }
4663
4664 public boolean marker(int hDisplay)
4665 {
4666 if (hDisplay < 0 || hDisplay >= n_display)
4667 return marker();
4668 else if (histo[hDisplay] == null)
4669 return false;
4670 else
4671 return histo[hDisplay].markerFlag != 0 ? true : false;
4672 }
4673
4674 public boolean marker(boolean MarkerOn)
4675 {
4676 return marker(MarkerOn, -1);
4677 }
4678
4679 public boolean marker(boolean MarkerOn, int hDisplay)
4680 {
4681 int num, ende;
4682 m_marker = MarkerOn ? 2 : 0;
4683 num = hDisplay;
4684 if (num < 0 || num >= n_display)
4685 {
4686 num = 0;
4687 ende = n_display - 1;
4688 }
4689 else
4690 ende = num;
4691 for (; num <= ende; num++)
4692 {
4693 if (histo[num] == null) continue;
4694 if (m_marker == 0)
4695 histo[num].markerFlag = 0;
4696 else if (histo[num].displayON != 0) histo[num].markerFlag = 1;
4697 }
4698 if (m_marker == 2) setmarkerflag(1);
4699
4700 if (aFrame.drawFlag)
4701 prepareDraw();
4702 else
4703 changeScaleWidth = 0;
4704 return m_marker != 0 ? true : false;
4705 }
4706 protected void setmarkerflag(int flag)
4707 {
4708 for (int n = 0; n < n_display; n++)
4709 {
4710 if (histo[n] == null) break;
4711 if (flag == 2 || histo[n].displayON != 0) histo[n].marker_ary_cpy = flag;
4712 }
4713 }
4714 public boolean isTagged(int index, int hDisplay)
4715 {
4716 return isTagged(index, -1, hDisplay);
4717 }
4718 public boolean isTagged(int index, int value, int hDisplay)
4719 {
4720 boolean tagon;
4721 int j, found, lasfDisp, lastTagON, start, stop;
4722 if (pTagColorArray == null) return false;
4723 if (index < -1) return false;
4724 found = 0;
4725 lastTagON = -1;
4726 if (hDisplay >= 0 && hDisplay < n_display)
4727 {
4728 start = hDisplay;
4729 stop = start + 1;
4730 }
4731 else
4732 {
4733 start = 0;
4734 stop = n_display;
4735 }
4736 tagon = value == 1 ? true : false;
4737 for (j = start; j < stop; j++)
4738 {
4739 if (histo[j] == null) break;
4740 if (histo[j].dismode == AcopConst.mode_histogram
4741 || histo[j].dismode == AcopConst.mode_histogram_rastoring
4742 || histo[j].dismode == AcopConst.mode_dots || histo[j].dismode == AcopConst.mode_rectangle
4743 || histo[j].dismode == AcopConst.mode_circle)
4744 {
4745 if (index >= histo[j].npoints) continue;
4746 if (found == 0)
4747 {
4748 if (value < 0 || value > 1)
4749
4750 return index == -1 ? m_tagging : (histo[j].m_tagColorArray[index] == histo[j].vorColor ? false
4751 : true);
4752 found = 1;
4753 lasfDisp = j;
4754 }
4755 if (index != -1)
4756 histo[j].m_tagColorArray[index] = tagon ? histo[j].tagColor : histo[j].vorColor;
4757 else
4758
4759 for (int i = 0; i < histo[j].npoints; i++)
4760 histo[j].m_tagColorArray[i] = tagon ? histo[j].tagColor : histo[j].vorColor;
4761 if (histo[j].tagHist != 0) lasfDisp = j;
4762 if (j == lastTagHisto && histo[j].displayON != 0) lastTagON = j;
4763 }
4764 }
4765 if (found == 0) return false;
4766
4767 if (lastTagON >= 0) lastDisp = lastTagON;
4768 if (m_tagging && aFrame.drawFlag)
4769 {
4770 if (index == -1)
4771 repaintHisto();
4772 else
4773 {
4774 int xpos, left, right, low = 0, high = 0;
4775
4776 for (lasfDisp = start; lasfDisp < stop; lasfDisp++)
4777 {
4778 if (histo[lasfDisp] == null) break;
4779 xpos = histo[lasfDisp].ix[index];
4780 if (histo[lasfDisp].dismode == AcopConst.mode_histogram
4781 || histo[lasfDisp].dismode == AcopConst.mode_histogram_rastoring)
4782 {
4783 left = xpos - histo[lasfDisp].penWidth;
4784 right = xpos + histo[lasfDisp].penWidth;
4785 }
4786 else
4787 {
4788 left = xpos - histo[lasfDisp].xextent;
4789 right = xpos + histo[lasfDisp].xextent;
4790 }
4791 if (lasfDisp == start)
4792 {
4793 low = left;
4794 high = right;
4795 continue;
4796 }
4797 if (low > left) low = left;
4798 if (high < right) high = right;
4799 }
4800 tagRect.x = low + aFrame.histRect.x;
4801 tagRect.width = high - low;
4802 repaintTagging();
4803 }
4804 }
4805 return tagon;
4806 }
4807 protected void repaintTagging()
4808 {
4809 this.repaint(tagRect.x, tagRect.y, tagRect.width, tagRect.height);
4810 }
4811 public int getTaggedColor(Color[] ColorArray, int Npoints, int StartIndex, int hDisplay)
4812 {
4813 int format, num, start, ndata;
4814 int aryType, refType, NoInputY, DataSize, i, j, k;
4815 if (hDisplay < 0 || hDisplay >= n_display || histo[hDisplay] == null
4816 || histo[hDisplay].m_tagColorArray == null) return -1;
4817 num = Npoints;
4818 if (num < 1) num = histo[hDisplay].npoints;
4819 start = StartIndex;
4820 if (start < 0 || start >= histo[hDisplay].npoints) return -8;
4821 if (num + start > histo[hDisplay].npoints) num = histo[hDisplay].npoints - start;
4822 num += start;
4823 if (ColorArray == null) return -2;
4824 ndata = ColorArray.length;
4825 if (ndata < num - start) num = start + ndata;
4826 for (k = start; k < num; k++)
4827 {
4828 i = k - start;
4829 j = k < histo[hDisplay].npoints ? k : (k - histo[hDisplay].npoints);
4830 ColorArray[i] = histo[hDisplay].m_tagColorArray[j];
4831 }
4832 return num - start;
4833 }
4834
4835 public void setForeground(Color c)
4836 {
4837
4838 if (foreColor == c) return;
4839
4840 Color oldValue = getForeground();
4841 super.setForeground(c);
4842 foreColor = c;
4843 if (randomData == true)
4844 {
4845 rescaleFlag = 2;
4846 prepareDraw();
4847 }
4848
4849 firePropertyChange("foreground", oldValue, foreColor);
4850 }
4851
4852
4853
4854
4855
4856 public void setBackground(Color c)
4857 {
4858 if (backColor == c) return;
4859 Color oldValue = getBackground();
4860 super.setBackground(c);
4861
4862 if (m_cursorMarkerColor != null) rev_cursorMarkerColor = new Color(~m_cursorMarkerColor.getRGB() ^ ~c.getRGB());
4863 backColor = c;
4864 firePropertyChange("background", oldValue, backColor);
4865 }
4866
4867
4868
4869
4870
4871 JScrollPane listTextBox;
4872 JTextArea textArea;
4873 protected java.lang.String caption = "";
4874 protected int captionPosition;
4875 protected int barlineColorFilled;
4876 protected int frameWidth;
4877
4878 protected int frameLeftOffset;
4879 protected int frameRightOffset;
4880 protected int frameTopOffset;
4881 protected int frameBottomOffset;
4882 protected int displayMode;
4883
4884
4885
4886
4887 protected int drawWidth;
4888
4889
4890 protected double XScale;
4891 protected double XShift;
4892 protected int graphStyle;
4893
4894 protected double YScale;
4895 protected boolean wrapAround;
4896 protected double YShift;
4897 protected double YExtent;
4898 protected int screenDepth;
4899 protected int keepStyle;
4900
4901
4902 protected int zooming;
4903
4904 protected int keepWidth;
4905 protected boolean randomData;
4906 protected boolean randomText;
4907
4908 protected boolean invert;
4909 protected int drawStyle;
4910
4911 protected boolean reuseText;
4912 protected java.awt.Color keepColor;
4913
4914 protected int averagingMode, averagingDepth;
4915 protected int FFT;
4916 protected double XExtent;
4917
4918
4919
4920 protected boolean reuseScreen;
4921 protected int textDepth;
4922
4923
4924 protected boolean colorFilled;
4925
4926 protected int xlabelRotation;
4927 protected int printTextStickyAttribute;
4928 protected int printTextLocation;
4929 protected int printTextRotation;
4930 protected java.awt.Color m_tagColor;
4931 protected boolean m_tagging;
4932 protected java.awt.Color m_errorColor;
4933 protected java.awt.Color LeadingEdgeColor;
4934 protected int LeadingEdgeGapSize;
4935 protected int LeadingEdgeMotion;
4936 protected int LeadingEdgeMode;
4937 protected int LeadingEdgeWidth;
4938 protected int LeadingEdgeStyle;
4939 protected double LeadingEdgeXExtent;
4940 protected double LeadingEdgeYExtent;
4941 protected java.awt.Color m_markerColor;
4942 protected int m_markerMode;
4943 protected int m_markerStyle;
4944 protected int m_markerWidth;
4945 protected double m_markerXExtent;
4946 protected double m_markerYExtent;
4947 protected java.awt.Color m_cursorMarkerColor;
4948 protected java.awt.Color rev_cursorMarkerColor;
4949 protected int m_cursorMarkerMode;
4950 protected int m_cursorMarkerStyle;
4951 protected int m_cursorMarkerWidth;
4952 protected double m_cursorMarkerXExtent;
4953 protected double m_cursorMarkerYExtent;
4954 private AcopTransport acopTransport = null;
4955
4956
4957
4958 public AcopTransport getAcopTransport()
4959 {
4960 if (acopTransport == null) acopTransport = new AcopTransport();
4961 return acopTransport;
4962 }
4963
4964
4965
4966 public void setAcopTransport(AcopTransport acopTransport)
4967 {
4968 this.acopTransport = acopTransport;
4969 }
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979 public PopupManager getPopupManager()
4980 {
4981 if (popupManager == null) {
4982 popupManager = new PopupManager(this, false);
4983 popupManager.addAction(new AbstractAction("Preferences...") {
4984 private static final long serialVersionUID = 1L;
4985
4986 public void actionPerformed(ActionEvent e)
4987 {
4988 getCustomizer().showDialog();
4989 }
4990 });
4991 }
4992
4993 return popupManager;
4994 }
4995
4996
4997
4998
4999
5000
5001 public boolean isPopupEnabled() {
5002 return popupEnabled;
5003 }
5004
5005
5006
5007
5008
5009
5010 public void setPopupEnabled(boolean enabled) {
5011 if (popupEnabled == enabled) return;
5012 popupEnabled = enabled;
5013 if (enabled) {
5014 addMouseListener(getPopupManager().getMouseHook());
5015 } else {
5016 removeMouseListener(getPopupManager().getMouseHook());
5017 }
5018 firePropertyChange("popupEnabled",!popupEnabled,popupEnabled);
5019 }
5020
5021
5022
5023
5024
5025 public AbstractCustomizerPanel getCustomizer()
5026 {
5027 if (customizer == null) {
5028 customizer = AbstractCustomizerPanel.findCustomizer(this);
5029 customizer.setObject(this);
5030 }
5031
5032 return customizer;
5033 }
5034
5035 public boolean isZoomFlag() {
5036 return zoomFlag;
5037 }
5038
5039
5040
5041
5042
5043
5044
5045 public void setForceWidth(boolean force) {
5046 if (forceWidth == force) return;
5047 this.forceWidth = force;
5048 firePropertyChange("forceWidth",!forceWidth,forceWidth);
5049 }
5050
5051
5052
5053
5054
5055
5056 public boolean isForceWidth() {
5057 return forceWidth;
5058 }
5059 }