1 | package vishnu.testvis.dendro;
|
---|
2 |
|
---|
3 | import javax.swing.*;
|
---|
4 | import javax.swing.text.html.*;
|
---|
5 | import javax.swing.event.*;
|
---|
6 | import java.awt.*;
|
---|
7 | import java.awt.event.*;
|
---|
8 | import java.util.Vector;
|
---|
9 | import vishnu.testvis.visual.*;
|
---|
10 |
|
---|
11 | class HLinkPanel extends JEditorPane {
|
---|
12 |
|
---|
13 | public JScrollPane linkPane;
|
---|
14 | public Vishnu currentMain;
|
---|
15 | public int index = 0;
|
---|
16 |
|
---|
17 | public int numDisplayedDocs = 15;
|
---|
18 |
|
---|
19 | public HLinkPanel(int width,int length, Vishnu currentMain) {
|
---|
20 |
|
---|
21 | linkPane = new JScrollPane(this);
|
---|
22 | this.currentMain=currentMain;
|
---|
23 | linkPane.setBorder(BorderFactory.createLoweredBevelBorder());
|
---|
24 | linkPane.setPreferredSize(new Dimension(width,length));
|
---|
25 | //linkPane.setMinimumSize(new Dimension(width,length));
|
---|
26 | linkPane.setBorder(new javax.swing.border.EtchedBorder());
|
---|
27 | linkPane.getVerticalScrollBar().setUnitIncrement(10);
|
---|
28 |
|
---|
29 | setLayout(new GridLayout(17,1));
|
---|
30 |
|
---|
31 |
|
---|
32 | setEditorKitForContentType("text/html",new HTMLEditorKit());
|
---|
33 | setEditorKit(new HTMLEditorKit());
|
---|
34 | setEditable(false);
|
---|
35 |
|
---|
36 | addHyperlinkListener(new MyLinkListener());
|
---|
37 |
|
---|
38 | setVisible(true);
|
---|
39 |
|
---|
40 | }
|
---|
41 |
|
---|
42 | public class MyLinkListener implements HyperlinkListener{
|
---|
43 | public void hyperlinkUpdate(HyperlinkEvent he){
|
---|
44 | //System.out.println("Inside hyperlinkevent ... ");
|
---|
45 | HyperlinkEvent.EventType type = he.getEventType();
|
---|
46 | //System.out.println("Inside hyperlinkevent ... ");
|
---|
47 | if (type==HyperlinkEvent.EventType.ACTIVATED)
|
---|
48 | {
|
---|
49 |
|
---|
50 | String hpresult = he.getDescription();
|
---|
51 | int index = Integer.parseInt(hpresult);
|
---|
52 | System.out.println("hyperlink result: " + index);
|
---|
53 | if (index > 0)
|
---|
54 | currentMain.dataManager.fetchDocNo(index);
|
---|
55 | }
|
---|
56 | }
|
---|
57 | }
|
---|
58 |
|
---|
59 | /*public void update()
|
---|
60 | {
|
---|
61 | int count = currentMain.dataManager.getDocCount();
|
---|
62 | Vector subSet = new Vector(count);
|
---|
63 |
|
---|
64 | for (int i = index ; i < index + numDisplayedDocs ; i++)
|
---|
65 | {
|
---|
66 | subSet.addElement(new Integer(i));
|
---|
67 | }
|
---|
68 |
|
---|
69 | String htmlDescription = currentMain.dataManager.getDocumentDescription(subSet);
|
---|
70 |
|
---|
71 | setText(htmlDescription);
|
---|
72 |
|
---|
73 | }*/
|
---|
74 |
|
---|
75 | public void clear()
|
---|
76 | {
|
---|
77 | setText("");
|
---|
78 | }
|
---|
79 |
|
---|
80 | }
|
---|