Rev 3662 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3662 | Rev 7246 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
2 | |
2 | Sketch Elements: Chemistry molecular diagram drawing tool. |
3 | |
3 | |
4 | (c) 2005 Dr. Alex M. Clark |
4 | (c) 2005 Dr. Alex M. Clark |
5 | |
5 | |
6 | Released as GNUware, under the Gnu Public License (GPL) |
6 | Released as GNUware, under the Gnu Public License (GPL) |
7 | |
7 | |
Line 28... | Line 28... | ||
28 | public FileMolPreview(JFileChooser fc) |
28 | public FileMolPreview(JFileChooser fc) |
29 | { |
29 | { |
30 | super(200,200); |
30 | super(200,200); |
31 | fc.addPropertyChangeListener(this); |
31 | fc.addPropertyChangeListener(this); |
32 | setBackground(Color.WHITE); |
32 | setBackground(Color.WHITE); |
33 |
|
33 | setBorder(true); |
34 |
|
34 | setToolCursor(); |
35 |
|
35 | setEditable(false); |
36 | } |
36 | } |
37 | 37 | ||
38 | public void propertyChange(PropertyChangeEvent ev) |
38 | public void propertyChange(PropertyChangeEvent ev) |
39 | { |
39 | { |
40 | boolean update=false; |
40 | boolean update=false; |
Line 58... | Line 58... | ||
58 | if (file!=null && file.isFile()) |
58 | if (file!=null && file.isFile()) |
59 | { |
59 | { |
60 | try |
60 | try |
61 | { |
61 | { |
62 | FileInputStream istr=new FileInputStream(file); |
62 | FileInputStream istr=new FileInputStream(file); |
63 | mol=MoleculeStream. |
63 | mol=MoleculeStream.readUnknown(istr); |
64 | istr.close(); |
64 | istr.close(); |
65 | } |
65 | } |
66 | catch (IOException e) |
66 | catch (IOException e) |
67 | { |
67 | { |
68 | mol=null; |
68 | mol=null; |
69 | } |
69 | } |
70 | } |
70 | } |
71 | if (mol==null) mol=new Molecule(); |
71 | if (mol==null) mol=new Molecule(); |
72 |
|
72 | replace(mol); |
73 |
|
73 | scaleToFit(); |
74 | if (isShowing()) repaint(); |
74 | if (isShowing()) repaint(); |
75 | } |
75 | } |
76 | } |
76 | } |
77 | 77 | ||
78 | protected void paintComponent(Graphics g) |
78 | protected void paintComponent(Graphics g) |