JAL-2975 Shift-arrow keys to rotate PCA incrementally
[jalview.git] / src / jalview / gui / RotatableCanvas.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.gui;
22
23 import jalview.api.RotatableCanvasI;
24 import jalview.datamodel.Point;
25 import jalview.datamodel.SequenceGroup;
26 import jalview.datamodel.SequenceI;
27 import jalview.datamodel.SequencePoint;
28 import jalview.math.RotatableMatrix;
29 import jalview.math.RotatableMatrix.Axis;
30 import jalview.util.ColorUtils;
31 import jalview.util.MessageManager;
32 import jalview.viewmodel.AlignmentViewport;
33
34 import java.awt.Color;
35 import java.awt.Dimension;
36 import java.awt.Font;
37 import java.awt.Graphics;
38 import java.awt.Graphics2D;
39 import java.awt.Image;
40 import java.awt.RenderingHints;
41 import java.awt.event.InputEvent;
42 import java.awt.event.KeyEvent;
43 import java.awt.event.KeyListener;
44 import java.awt.event.MouseEvent;
45 import java.awt.event.MouseListener;
46 import java.awt.event.MouseMotionListener;
47 import java.awt.event.MouseWheelEvent;
48 import java.awt.event.MouseWheelListener;
49 import java.util.Arrays;
50 import java.util.Iterator;
51 import java.util.List;
52
53 import javax.swing.JPanel;
54 import javax.swing.ToolTipManager;
55
56 /**
57  * Models a Panel on which a set of points, and optionally x/y/z axes, can be
58  * drawn, and rotated or zoomed with the mouse
59  */
60 public class RotatableCanvas extends JPanel implements MouseListener,
61         MouseMotionListener, KeyListener, RotatableCanvasI,
62         MouseWheelListener
63 {
64   private static final float ZOOM_OUT = 0.9f;
65
66   private static final float ZOOM_IN = 1.1f;
67
68   /*
69    * pixels distance within which tooltip shows sequence name
70    */
71   private static final int NEARBY = 3;
72
73   private static final List<String> AXES = Arrays.asList("x", "y", "z");
74
75   private static final Color AXIS_COLOUR = Color.yellow;
76
77   private static final int DIMS = 3;
78
79   boolean drawAxes = true;
80
81   int mouseX;
82
83   int mouseY;
84
85   Image img;
86
87   Graphics ig;
88
89   Dimension prefSize;
90
91   /*
92    * the min-max [x, y, z] values of sequence points when the points
93    * were set on the object, or when the view is reset; 
94    * x and y ranges are not recomputed as points are rotated, as this
95    * would make scaling (zoom) unstable, but z ranges are (for correct
96    * graduated colour brightness based on z-coordinate)
97    */
98   float[] seqMin;
99
100   float[] seqMax;
101
102   /*
103    * a scale factor used in drawing; when equal to 1, the points span
104    * half the available width or height (whichever is less); increase this
105    * factor to zoom in, decrease it to zoom out
106    */
107   float scaleFactor;
108
109   int npoint;
110
111   /*
112    * sequences and their (x, y, z) PCA dimension values
113    */
114   List<SequencePoint> sequencePoints;
115
116   /*
117    * x, y, z axis end points (PCA dimension values)
118    */
119   Point[] axisEndPoints;
120
121   // fields for 'select rectangle' (JAL-1124)
122   // int rectx1;
123   // int recty1;
124   // int rectx2;
125   // int recty2;
126
127   AlignmentViewport av;
128
129   AlignmentPanel ap;
130
131   boolean showLabels;
132
133   Color bgColour;
134
135   boolean applyToAllViews;
136
137   /**
138    * Constructor
139    * 
140    * @param panel
141    */
142   public RotatableCanvas(AlignmentPanel panel)
143   {
144     this.av = panel.av;
145     this.ap = panel;
146     axisEndPoints = new Point[DIMS];
147     showLabels = false;
148     applyToAllViews = false;
149     bgColour = Color.BLACK;
150     resetAxes();
151
152     ToolTipManager.sharedInstance().registerComponent(this);
153
154     addMouseListener(this);
155     addMouseMotionListener(this);
156     addMouseWheelListener(this);
157   }
158
159   /**
160    * Refreshes the display with labels shown (or not)
161    * 
162    * @param show
163    */
164   public void showLabels(boolean show)
165   {
166     showLabels = show;
167     repaint();
168   }
169
170   @Override
171   public void setPoints(List<SequencePoint> points, int np)
172   {
173     this.sequencePoints = points;
174     this.npoint = np;
175     prefSize = getPreferredSize();
176
177     findWidths();
178
179     scaleFactor = 1f;
180   }
181
182   /**
183    * Resets axes to the initial state: x-axis to the right, y-axis up, z-axis to
184    * back (so obscured in a 2-D display)
185    */
186   protected void resetAxes()
187   {
188     axisEndPoints[0] = new Point(1f, 0f, 0f);
189     axisEndPoints[1] = new Point(0f, 1f, 0f);
190     axisEndPoints[2] = new Point(0f, 0f, 1f);
191   }
192
193   /**
194    * Computes and saves the min-max ranges of x/y/z positions of the sequence
195    * points
196    */
197   protected void findWidths()
198   {
199     float[] max = new float[DIMS];
200     float[] min = new float[DIMS];
201     
202     max[0] = -Float.MAX_VALUE;
203     max[1] = -Float.MAX_VALUE;
204     max[2] = -Float.MAX_VALUE;
205     
206     min[0] = Float.MAX_VALUE;
207     min[1] = Float.MAX_VALUE;
208     min[2] = Float.MAX_VALUE;
209     
210     for (SequencePoint sp : sequencePoints)
211     {
212       max[0] = Math.max(max[0], sp.coord.x);
213       max[1] = Math.max(max[1], sp.coord.y);
214       max[2] = Math.max(max[2], sp.coord.z);
215       min[0] = Math.min(min[0], sp.coord.x);
216       min[1] = Math.min(min[1], sp.coord.y);
217       min[2] = Math.min(min[2], sp.coord.z);
218     }
219     
220     seqMin = min;
221     seqMax = max;
222   }
223
224   /**
225    * Answers the preferred size if it has been set, else 400 x 400
226    * 
227    * @return
228    */
229   @Override
230   public Dimension getPreferredSize()
231   {
232     if (prefSize != null)
233     {
234       return prefSize;
235     }
236     else
237     {
238       return new Dimension(400, 400);
239     }
240   }
241
242   /**
243    * Answers the preferred size
244    * 
245    * @return
246    * @see RotatableCanvas#getPreferredSize()
247    */
248   @Override
249   public Dimension getMinimumSize()
250   {
251     return getPreferredSize();
252   }
253
254   /**
255    * Repaints the panel
256    * 
257    * @param g
258    */
259   @Override
260   public void paintComponent(Graphics g1)
261   {
262
263     Graphics2D g = (Graphics2D) g1;
264
265     g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
266             RenderingHints.VALUE_ANTIALIAS_ON);
267     if (sequencePoints == null)
268     {
269       g.setFont(new Font("Verdana", Font.PLAIN, 18));
270       g.drawString(
271               MessageManager.getString("label.calculating_pca") + "....",
272               20, getHeight() / 2);
273     }
274     else
275     {
276       /*
277        * create the image at the beginning or after a resize
278        */
279       boolean resized = prefSize.width != getWidth()
280               || prefSize.height != getHeight();
281       if (img == null || resized)
282       {
283         prefSize.width = getWidth();
284         prefSize.height = getHeight();
285
286         img = createImage(getWidth(), getHeight());
287         ig = img.getGraphics();
288       }
289
290       drawBackground(ig, bgColour);
291       drawScene(ig);
292
293       if (drawAxes)
294       {
295         drawAxes(ig);
296       }
297
298       g.drawImage(img, 0, 0, this);
299     }
300   }
301
302   /**
303    * Resets the rotation and choice of axes to the initial state (without change
304    * of scale factor)
305    */
306   public void resetView()
307   {
308     img = null;
309     findWidths();
310     resetAxes();
311     repaint();
312   }
313
314   /**
315    * Draws lines for the x, y, z axes
316    * 
317    * @param g
318    */
319   public void drawAxes(Graphics g)
320   {
321     g.setColor(AXIS_COLOUR);
322
323     int midX = getWidth() / 2;
324     int midY = getHeight() / 2;
325     float maxWidth = Math.max(Math.abs(seqMax[0] - seqMin[0]),
326             Math.abs(seqMax[1] - seqMin[1]));
327     int pix = Math.min(getWidth(), getHeight());
328     float scaleBy = pix * scaleFactor / (2f * maxWidth);
329
330     for (int i = 0; i < DIMS; i++)
331     {
332       g.drawLine(midX, midY,
333               midX + (int) (axisEndPoints[i].x * scaleBy * seqMax[0]),
334               midY + (int) (axisEndPoints[i].y * scaleBy * seqMax[1]));
335     }
336   }
337
338   /**
339    * Fills the background with the specified colour
340    * 
341    * @param g
342    * @param col
343    */
344   public void drawBackground(Graphics g, Color col)
345   {
346     g.setColor(col);
347     g.fillRect(0, 0, prefSize.width, prefSize.height);
348   }
349
350   /**
351    * Draws points (6x6 squares) for the sequences of the PCA, and labels
352    * (sequence names) if configured to do so. The sequence points colours are
353    * taken from the sequence ids in the alignment (converting black to white).
354    * Sequences 'at the back' (z-coordinate is negative) are shaded slightly
355    * darker to help give a 3-D sensation.
356    * 
357    * @param g
358    */
359   public void drawScene(Graphics g1)
360   {
361     Graphics2D g = (Graphics2D) g1;
362
363     g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
364             RenderingHints.VALUE_ANTIALIAS_ON);
365     int pix = Math.min(getWidth(), getHeight());
366     float xWidth = Math.abs(seqMax[0] - seqMin[0]);
367     float yWidth = Math.abs(seqMax[1] - seqMin[1]);
368     float maxWidth = Math.max(xWidth, yWidth);
369     float scaleBy = pix * scaleFactor / (2f * maxWidth);
370
371     float[] centre = getCentre();
372
373     for (int i = 0; i < npoint; i++)
374     {
375       /*
376        * sequence point colour as sequence id, but
377        * gray if sequence is currently selected
378        */
379       SequencePoint sp = sequencePoints.get(i);
380       Color sequenceColour = getSequencePointColour(sp);
381       g.setColor(sequenceColour);
382
383       int halfwidth = getWidth() / 2;
384       int halfheight = getHeight() / 2;
385       int x = (int) ((sp.coord.x - centre[0]) * scaleBy) + halfwidth;
386       int y = (int) ((sp.coord.y - centre[1]) * scaleBy) + halfheight;
387       g.fillRect(x - 3, y - 3, 6, 6);
388
389       if (showLabels)
390       {
391         g.setColor(Color.red);
392         g.drawString(sp.getSequence().getName(), x - 3, y - 4);
393       }
394     }
395     if (showLabels)
396     {
397       g.setColor(AXIS_COLOUR);
398       int midX = getWidth() / 2;
399       int midY = getHeight() / 2;
400       Iterator<String> axes = AXES.iterator();
401       for (Point p : axisEndPoints)
402       {
403         int x = midX + (int) (p.x * scaleBy * seqMax[0]);
404         int y = midY + (int) (p.y * scaleBy * seqMax[1]);
405         g.drawString(axes.next(), x - 3, y - 4);
406       }
407     }
408     // //Now the rectangle
409     // if (rectx2 != -1 && recty2 != -1) {
410     // g.setColor(Color.white);
411     //
412     // g.drawRect(rectx1,recty1,rectx2-rectx1,recty2-recty1);
413     // }
414   }
415
416   /**
417    * Determines the colour to use when drawing a sequence point. The colour is
418    * taken from the sequence id, with black converted to white, and then
419    * graduated from darker (at the back) to brighter (at the front) based on the
420    * z-axis coordinate of the point.
421    * 
422    * @param sp
423    * @return
424    */
425   protected Color getSequencePointColour(SequencePoint sp)
426   {
427     SequenceI sequence = sp.getSequence();
428     Color sequenceColour = av.getSequenceColour(sequence);
429     if (sequenceColour == Color.black)
430     {
431       sequenceColour = Color.white;
432     }
433     if (av.getSelectionGroup() != null)
434     {
435       if (av.getSelectionGroup().getSequences(null).contains(sequence))
436       {
437         sequenceColour = Color.gray;
438       }
439     }
440
441     /*
442      * graduate brighter for point in front of centre, darker if behind centre
443      */
444     float zCentre = (seqMin[2] + seqMax[2]) / 2f;
445     if (sp.coord.z > zCentre)
446     {
447       sequenceColour = ColorUtils.getGraduatedColour(sp.coord.z, 0,
448               sequenceColour, seqMax[2], sequenceColour.brighter());
449     }
450     else if (sp.coord.z < zCentre)
451     {
452       sequenceColour = ColorUtils.getGraduatedColour(sp.coord.z, seqMin[2],
453               sequenceColour.darker(), 0, sequenceColour);
454     }
455
456     return sequenceColour;
457   }
458
459   @Override
460   public void keyTyped(KeyEvent evt)
461   {
462   }
463
464   @Override
465   public void keyReleased(KeyEvent evt)
466   {
467   }
468
469   /**
470    * Responds to up or down arrow key by zooming in or out, respectively
471    * 
472    * @param evt
473    */
474   @Override
475   public void keyPressed(KeyEvent evt)
476   {
477     int keyCode = evt.getKeyCode();
478     boolean shiftDown = evt.isShiftDown();
479
480     if (keyCode == KeyEvent.VK_UP)
481     {
482       if (shiftDown)
483       {
484         rotate(0f, -1f);
485       }
486       else
487       {
488         zoom(ZOOM_IN);
489       }
490     }
491     else if (keyCode == KeyEvent.VK_DOWN)
492     {
493       if (shiftDown)
494       {
495         rotate(0f, 1f);
496       }
497       else
498       {
499         zoom(ZOOM_OUT);
500       }
501     }
502     else if (shiftDown && keyCode == KeyEvent.VK_LEFT)
503     {
504       rotate(1f, 0f);
505     }
506     else if (shiftDown && keyCode == KeyEvent.VK_RIGHT)
507     {
508       rotate(-1f, 0f);
509     }
510     else if (evt.getKeyChar() == 's')
511     {
512       // Cache.log.warn("DEBUG: Rectangle selection");
513       // todo not yet enabled as rectx2, recty2 are always -1
514       // need to set them in mouseDragged; JAL-1124
515       // if ((rectx2 != -1) && (recty2 != -1))
516       // {
517       // rectSelect(rectx1, recty1, rectx2, recty2);
518       // }
519     }
520
521     repaint();
522   }
523
524   @Override
525   public void zoom(float factor)
526   {
527     if (factor > 0f)
528     {
529       scaleFactor *= factor;
530     }
531   }
532
533   @Override
534   public void mouseClicked(MouseEvent evt)
535   {
536   }
537
538   @Override
539   public void mouseEntered(MouseEvent evt)
540   {
541   }
542
543   @Override
544   public void mouseExited(MouseEvent evt)
545   {
546   }
547
548   @Override
549   public void mouseReleased(MouseEvent evt)
550   {
551   }
552
553   /**
554    * If the mouse press is at (within 2 pixels of) a sequence point, toggles
555    * (adds or removes) the corresponding sequence as a member of the viewport
556    * selection group. This supports configuring a group in the alignment by
557    * clicking on points in the PCA display.
558    */
559   @Override
560   public void mousePressed(MouseEvent evt)
561   {
562     int x = evt.getX();
563     int y = evt.getY();
564
565     mouseX = x;
566     mouseY = y;
567
568     // rectx1 = x;
569     // recty1 = y;
570     // rectx2 = -1;
571     // recty2 = -1;
572
573     SequenceI found = findSequenceAtPoint(x, y);
574
575     if (found != null)
576     {
577       AlignmentPanel[] aps = getAssociatedPanels();
578
579       for (int a = 0; a < aps.length; a++)
580       {
581         if (aps[a].av.getSelectionGroup() != null)
582         {
583           aps[a].av.getSelectionGroup().addOrRemove(found, true);
584         }
585         else
586         {
587           aps[a].av.setSelectionGroup(new SequenceGroup());
588           aps[a].av.getSelectionGroup().addOrRemove(found, true);
589           aps[a].av.getSelectionGroup()
590                   .setEndRes(aps[a].av.getAlignment().getWidth() - 1);
591         }
592       }
593       PaintRefresher.Refresh(this, av.getSequenceSetId());
594       // canonical selection is sent to other listeners
595       av.sendSelection();
596     }
597
598     repaint();
599   }
600
601   /**
602    * Sets the tooltip to the name of the sequence within 2 pixels of the mouse
603    * position, or clears the tooltip if none found
604    */
605   @Override
606   public void mouseMoved(MouseEvent evt)
607   {
608     SequenceI found = findSequenceAtPoint(evt.getX(), evt.getY());
609
610     this.setToolTipText(found == null ? null : found.getName());
611   }
612
613   /**
614    * Action handler for a mouse drag. Rotates the display around the X axis (for
615    * up/down mouse movement) and/or the Y axis (for left/right mouse movement).
616    * 
617    * @param evt
618    */
619   @Override
620   public void mouseDragged(MouseEvent evt)
621   {
622     int xPos = evt.getX();
623     int yPos = evt.getY();
624
625     if (xPos == mouseX && yPos == mouseY)
626     {
627       return;
628     }
629
630     int xDelta = xPos - mouseX;
631     int yDelta = yPos - mouseY;
632
633     // Check if this is a rectangle drawing drag
634     if ((evt.getModifiers() & InputEvent.BUTTON2_MASK) != 0)
635     {
636       // rectx2 = evt.getX();
637       // recty2 = evt.getY();
638     }
639     else
640     {
641       rotate(xDelta, yDelta);
642
643       mouseX = xPos;
644       mouseY = yPos;
645
646       // findWidths();
647
648       repaint();
649     }
650   }
651
652   @Override
653   public void rotate(float x, float y)
654   {
655     if (x == 0f && y == 0f)
656     {
657       return;
658     }
659
660     /*
661      * get the identity transformation...
662      */
663     RotatableMatrix rotmat = new RotatableMatrix();
664
665     /*
666      * rotate around the X axis for change in Y
667      * (mouse movement up/down); note we are equating a
668      * number of pixels with degrees of rotation here!
669      */
670     if (y != 0)
671     {
672       rotmat.rotate(y, Axis.X);
673     }
674
675     /*
676      * rotate around the Y axis for change in X
677      * (mouse movement left/right)
678      */
679     if (x != 0)
680     {
681       rotmat.rotate(x, Axis.Y);
682     }
683
684     /*
685      * apply the composite transformation to sequence points;
686      * update z min-max range (affects colour graduation), but not
687      * x or y min-max (as this would affect axis scaling)
688      */
689     float[] centre = getCentre();
690     float zMin = Float.MAX_VALUE;
691     float zMax = -Float.MAX_VALUE;
692
693     for (int i = 0; i < npoint; i++)
694     {
695       SequencePoint sp = sequencePoints.get(i);
696       sp.translate(-centre[0], -centre[1], -centre[2]);
697
698       // Now apply the rotation matrix
699       sp.coord = rotmat.vectorMultiply(sp.coord);
700
701       // Now translate back again
702       sp.translate(centre[0], centre[1], centre[2]);
703       
704       zMin = Math.min(zMin, sp.coord.z);
705       zMax = Math.max(zMax, sp.coord.z);
706     }
707
708     seqMin[2] = zMin;
709     seqMax[2] = zMax;
710
711     /*
712      * rotate the x/y/z axis positions
713      */
714     for (int i = 0; i < DIMS; i++)
715     {
716       axisEndPoints[i] = rotmat.vectorMultiply(axisEndPoints[i]);
717     }
718   }
719
720   /**
721    * Answers the x/y/z coordinates that are midway between the maximum and
722    * minimum sequence point values
723    * 
724    * @return
725    */
726   private float[] getCentre()
727   {
728     float xCentre = (seqMin[0] + seqMax[0]) / 2f;
729     float yCentre = (seqMin[1] + seqMax[1]) / 2f;
730     float zCentre = (seqMin[2] + seqMax[2]) / 2f;
731
732     return new float[] { xCentre, yCentre, zCentre };
733   }
734
735   /**
736    * Adds any sequences whose displayed points are within the given rectangle to
737    * the viewport's current selection. Intended for key 's' after dragging to
738    * select a region of the PCA.
739    * 
740    * @param x1
741    * @param y1
742    * @param x2
743    * @param y2
744    */
745   protected void rectSelect(int x1, int y1, int x2, int y2)
746   {
747     float[] centre = getCentre();
748
749     for (int i = 0; i < npoint; i++)
750     {
751       SequencePoint sp = sequencePoints.get(i);
752       int tmp1 = (int) (((sp.coord.x - centre[0]) * scaleFactor)
753               + (getWidth() / 2.0));
754       int tmp2 = (int) (((sp.coord.y - centre[1]) * scaleFactor)
755               + (getHeight() / 2.0));
756
757       if ((tmp1 > x1) && (tmp1 < x2) && (tmp2 > y1) && (tmp2 < y2))
758       {
759         if (av != null)
760         {
761           SequenceI sequence = sp.getSequence();
762           if (!av.getSelectionGroup().getSequences(null)
763                   .contains(sequence))
764           {
765             av.getSelectionGroup().addSequence(sequence, true);
766           }
767         }
768       }
769     }
770   }
771
772   /**
773    * Answers the first sequence found whose point on the display is within 2
774    * pixels of the given coordinates, or null if none is found
775    * 
776    * @param x
777    * @param y
778    * 
779    * @return
780    */
781   protected SequenceI findSequenceAtPoint(int x, int y)
782   {
783     int halfwidth = getWidth() / 2;
784     int halfheight = getHeight() / 2;
785
786     int found = -1;
787     int pix = Math.min(getWidth(), getHeight());
788     float xWidth = Math.abs(seqMax[0] - seqMin[0]);
789     float yWidth = Math.abs(seqMax[1] - seqMin[1]);
790     float maxWidth = Math.max(xWidth, yWidth);
791     float scaleBy = pix * scaleFactor / (2f * maxWidth);
792
793     float[] centre = getCentre();
794
795     for (int i = 0; i < npoint; i++)
796     {
797       SequencePoint sp = sequencePoints.get(i);
798       int px = (int) ((sp.coord.x - centre[0]) * scaleBy)
799               + halfwidth;
800       int py = (int) ((sp.coord.y - centre[1]) * scaleBy)
801               + halfheight;
802
803       if ((Math.abs(px - x) < NEARBY) && (Math.abs(py - y) < NEARBY))
804       {
805         found = i;
806         break;
807       }
808     }
809
810     if (found != -1)
811     {
812       return sequencePoints.get(found).getSequence();
813     }
814     else
815     {
816       return null;
817     }
818   }
819
820   /**
821    * Answers the panel the PCA is associated with (all panels for this alignment
822    * if 'associate with all panels' is selected).
823    * 
824    * @return
825    */
826   AlignmentPanel[] getAssociatedPanels()
827   {
828     if (applyToAllViews)
829     {
830       return PaintRefresher.getAssociatedPanels(av.getSequenceSetId());
831     }
832     else
833     {
834       return new AlignmentPanel[] { ap };
835     }
836   }
837
838   public Color getBackgroundColour()
839   {
840     return bgColour;
841   }
842
843   /**
844    * Zooms in or out in response to mouse wheel movement
845    */
846   @Override
847   public void mouseWheelMoved(MouseWheelEvent e)
848   {
849     double wheelRotation = e.getPreciseWheelRotation();
850     if (wheelRotation > 0)
851     {
852       zoom(ZOOM_IN);
853       repaint();
854     }
855     else if (wheelRotation < 0)
856     {
857       zoom(ZOOM_OUT);
858       repaint();
859     }
860   }
861
862   /**
863    * Answers the sequence point minimum [x, y, z] values. Note these are derived
864    * when sequence points are set, but x and y values are not updated on
865    * rotation (because this would result in changes to scaling).
866    * 
867    * @return
868    */
869   public float[] getSeqMin()
870   {
871     return seqMin;
872   }
873
874   /**
875    * Answers the sequence point maximum [x, y, z] values. Note these are derived
876    * when sequence points are set, but x and y values are not updated on
877    * rotation (because this would result in changes to scaling).
878    * 
879    * @return
880    */
881   public float[] getSeqMax()
882   {
883     return seqMax;
884   }
885
886   /**
887    * Sets the minimum and maximum [x, y, z] positions for sequence points. For
888    * use when restoring a saved PCA from state data.
889    * 
890    * @param min
891    * @param max
892    */
893   public void setSeqMinMax(float[] min, float[] max)
894   {
895     seqMin = min;
896     seqMax = max;
897   }
898 }