Clover icon

Coverage Report

  1. Project Clover database Wed Nov 13 2024 18:27:33 GMT
  2. Package jalview.appletgui

File IdwidthAdjuster.java

 

Coverage histogram

../../img/srcFileCovDistChart0.png
59% of files have more coverage

Code metrics

2
22
8
1
124
70
10
0.45
2.75
8
1.25

Classes

Class Line # Actions
IdwidthAdjuster 31 22 10
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

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.appletgui;
22   
23    import java.awt.Color;
24    import java.awt.Cursor;
25    import java.awt.Dimension;
26    import java.awt.Panel;
27    import java.awt.event.MouseEvent;
28    import java.awt.event.MouseListener;
29    import java.awt.event.MouseMotionListener;
30   
 
31    public class IdwidthAdjuster extends Panel
32    implements MouseListener, MouseMotionListener
33    {
34    boolean active = false;
35   
36    int oldX = 0;
37   
38    AlignmentPanel ap;
39   
 
40  0 toggle public IdwidthAdjuster(AlignmentPanel ap)
41    {
42  0 setLayout(null);
43  0 this.ap = ap;
44  0 setBackground(Color.WHITE);
45  0 addMouseListener(this);
46  0 addMouseMotionListener(this);
47    }
48   
 
49  0 toggle @Override
50    public void mousePressed(MouseEvent evt)
51    {
52  0 oldX = evt.getX();
53    }
54   
 
55  0 toggle @Override
56    public void mouseReleased(MouseEvent evt)
57    {
58  0 active = false;
59  0 repaint();
60   
61    /*
62    * If in a SplitFrame with co-scaled alignments, set the other's id width to
63    * match; note applet does not (yet) store this in ViewStyle
64    */
65    /*
66    * Code disabled for now as it doesn't work, don't know why; idCanvas width
67    * keeps resetting to a previous value (actually two alternating values!)
68    */
69    // final AlignViewportI viewport = ap.getAlignViewport();
70    // if (viewport.getCodingComplement() != null
71    // && viewport.isScaleProteinAsCdna())
72    // {
73    // Dimension d = ap.idPanel.idCanvas.getSize();
74    // SplitFrame sf = ap.alignFrame.getSplitFrame();
75    // final AlignmentPanel otherPanel =
76    // sf.getComplement(ap.alignFrame).alignPanel;
77    // otherPanel.setIdWidth(d.width, d.height);
78    // otherPanel.repaint();
79    // }
80    }
81   
 
82  0 toggle @Override
83    public void mouseEntered(MouseEvent evt)
84    {
85  0 active = true;
86  0 setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));
87   
88  0 repaint();
89    }
90   
 
91  0 toggle @Override
92    public void mouseExited(MouseEvent evt)
93    {
94  0 active = false;
95  0 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
96  0 repaint();
97    }
98   
 
99  0 toggle @Override
100    public void mouseDragged(MouseEvent evt)
101    {
102  0 active = true;
103  0 Dimension d = ap.idPanel.idCanvas.getSize();
104  0 int dif = evt.getX() - oldX;
105   
106  0 final int newWidth = d.width + dif;
107  0 if (newWidth > 20 || dif > 0)
108    {
109  0 ap.setIdWidth(newWidth, d.height);
110  0 this.setSize(newWidth, getSize().height);
111  0 oldX = evt.getX();
112    }
113    }
114   
 
115  0 toggle @Override
116    public void mouseMoved(MouseEvent evt)
117    {
118    }
119   
 
120  0 toggle @Override
121    public void mouseClicked(MouseEvent evt)
122    {
123    }
124    }