source: trunk/greenstone3-extensions/vishnu/src/vishnu/testvis/dendro/HLinkPanel.java@ 8189

Last change on this file since 8189 was 8189, checked in by kjdon, 20 years ago

first version of Imperial College's Visualiser code

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 KB
Line 
1package vishnu.testvis.dendro;
2
3import javax.swing.*;
4import javax.swing.text.html.*;
5import javax.swing.event.*;
6import java.awt.*;
7import java.awt.event.*;
8import java.util.Vector;
9import vishnu.testvis.visual.*;
10
11class 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}
Note: See TracBrowser for help on using the repository browser.