1
2
3
4
5 package org.lsst.ccs.utilities.zonesui;
6
7 import javax.swing.JLabel;
8 import javax.swing.JPanel;
9 import javax.swing.JScrollPane;
10 import java.awt.BorderLayout;
11 import java.awt.Color;
12 import java.awt.Dimension;
13 import java.awt.Stroke;
14
15
16
17
18
19 public class ZonesPanel extends JPanel implements PositionListener{
20 private ImageZones imgZones ;
21 private JLabel markCoords = new JLabel(" ", JLabel.CENTER);
22
23 public ZonesPanel(ImageDescription id, InteractionProducer ip) {
24 imgZones = new ImageZones(id, ip, this);
25 setLayout(new BorderLayout());
26 JScrollPane scroll = new JScrollPane(imgZones, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
27 this.add(scroll) ;
28 this.add(markCoords, BorderLayout.PAGE_START);
29 }
30 @Override
31 public Dimension getPreferredSize() {
32 Dimension tailleEcran = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
33 Dimension tailleImage = imgZones.getPreferredSize();
34 if ((tailleImage.getHeight() < tailleEcran.getHeight()) && (tailleImage.getWidth() < tailleEcran.getWidth())) {
35 int labelHeight = markCoords.getHeight();
36 tailleImage.setSize(tailleImage.width, labelHeight + tailleImage.height);
37
38 return tailleImage;
39 }
40 else
41 return tailleEcran;
42
43 }
44 @Override
45 public Dimension getMinimumSize() {
46 int labelHeight = markCoords.getHeight();
47 Dimension dims = imgZones.getMinimumSize() ;
48 dims.setSize( dims.width, labelHeight + dims.height);
49
50 return dims ;
51 }
52
53 @Override
54 public void currentCoords(int x, int y) {
55 markCoords.setText("(" + x + "," + y + ")");
56 }
57
58 public void setStroke(Stroke stroke) {
59 imgZones.setStroke(stroke);
60 }
61
62 public void setDashedLineColor(Color color) {
63 imgZones.setDashedLineColor(color);
64 }
65
66 public void setDashedLineWidth(int points) {
67 imgZones.setDashedLineWidth(points);
68 }
69 }