~pixeldrama/annis/merge_restr_vis

« back to all changes in this revision

Viewing changes to annis-gui/src/main/java/annis/gui/resultview/VisualizerPanel.java

  • Committer: Benjamin Weißenfels
  • Date: 2012-08-16 19:53:31 UTC
  • Revision ID: b.pixeldrama@gmail.com-20120816195331-z7kd4av2yh5qitf5
Use KWIC as plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
import com.vaadin.ui.Button;
32
32
import com.vaadin.ui.Button.ClickEvent;
33
33
import com.vaadin.ui.CustomLayout;
 
34
import com.vaadin.ui.Label;
34
35
import com.vaadin.ui.Panel;
35
36
import com.vaadin.ui.themes.ChameleonTheme;
36
37
import de.hu_berlin.german.korpling.saltnpepper.salt.saltCommon.SaltProject;
45
46
import java.util.Map;
46
47
import java.util.Random;
47
48
import java.util.Set;
48
 
import java.util.logging.Level;
49
 
import java.util.logging.Logger;
 
49
import org.slf4j.Logger;
 
50
import org.slf4j.LoggerFactory;
50
51
 
51
52
/**
52
 
 * @author thomas
 
53
 * @author thomas, Benjamin Weißenfels
53
54
 *
54
55
 */
55
56
public class VisualizerPanel extends Panel implements Button.ClickListener
56
57
{
57
58
 
 
59
  private final Logger log = LoggerFactory.getLogger(VisualizerPanel.class);
58
60
  public static final ThemeResource ICON_COLLAPSE = new ThemeResource(
59
61
    "icon-collapse.gif");
60
62
  public static final ThemeResource ICON_EXPAND = new ThemeResource(
73
75
  private KWICPanel kwicPanel;
74
76
  private List<String> mediaIDs;
75
77
  private String htmlID;
76
 
  private final static Logger log = Logger.getLogger(
77
 
    VisualizerPanel.class.getName());
78
78
  private CustomLayout visContainer;
79
79
  private ComponentVisualizerPlugin compVis;
80
80
  private Set<String> visibleTokenAnnos;
92
92
    Set<String> visibleTokenAnnos, Map<SNode, Long> markedAndCovered,
93
93
    STextualDS text, List<String> mediaIDs,
94
94
    List<VisualizerPanel> mediaVisualizer, String htmlID,
95
 
    SingleResultPanel parent, String segmentationName, PluginSystem ps, 
 
95
    SingleResultPanel parent, String segmentationName, PluginSystem ps,
96
96
    CustomLayout visContainer)
97
97
  {
98
 
    VisualizerPlugin vis = ps.getVisualizer(visType);
 
98
    // get the Visualizer instance
 
99
    VisualizerPlugin tmpVis = ps.getVisualizer(visType);
 
100
    VisualizerPlugin vis = null;
 
101
    Label label;
 
102
 
 
103
    /**
 
104
     * build a new instance, cause the Pluginsystem holds only one instance of
 
105
     * the plugin.
 
106
     */
 
107
    try
 
108
    {
 
109
      vis = tmpVis.getClass().newInstance();
 
110
    }
 
111
    catch (InstantiationException ex)
 
112
    {
 
113
      log.error("could not initiate {}", tmpVis.getShortName(), ex);
 
114
    }
 
115
    catch (IllegalAccessException ex)
 
116
    {
 
117
      log.error("could not initiate {}", tmpVis.getShortName(), ex);
 
118
    }
99
119
 
100
120
    this.result = result;
101
121
    this.token = token;
103
123
    this.markedAndCovered = markedAndCovered;
104
124
    this.text = text;
105
125
    this.parentPanel = parent;
106
 
    this.segmentationName = segmentationName;    
 
126
    this.segmentationName = segmentationName;
107
127
    this.mediaVisualizer = mediaVisualizer;
108
128
    this.mediaIDs = mediaIDs;
109
129
    // TODO use this also for ComponentVisualizer, or lookup a native mediaplayer
110
130
    this.htmlID = htmlID;
111
 
    
 
131
 
112
132
    this.visContainer = visContainer;
113
133
 
114
134
    if (!(vis instanceof ComponentVisualizerPlugin))
115
135
    {
116
 
      log.warning(vis.getShortName() + " is not a ComponentVisualizer");
 
136
      log.warn("{} is not a ComponentVisualizer", vis.getShortName());
117
137
      return;
118
138
    }
119
139
 
120
140
    compVis = (ComponentVisualizerPlugin) vis;
121
141
    this.setWidth("100%");
122
 
    btEntry = new Button("KWIC");
 
142
    label = new Label("KWIC");
123
143
    this.setContent(this.visContainer);
124
 
    this.visContainer.addComponent(btEntry, "btEntry");
 
144
    this.visContainer.addComponent(label, "btEntry");
125
145
  }
126
146
 
127
147
  public VisualizerPanel(final ResolverEntry entry, SDocument result,
134
154
    this.entry = entry;
135
155
    this.markersExact = markersExact;
136
156
    this.markersCovered = markersCovered;
137
 
    this.visContainer = costumLayout;    
 
157
    this.visContainer = costumLayout;
138
158
    this.mediaIDs = mediaIDs;
139
159
    this.htmlID = htmlID;
140
 
    
 
160
 
141
161
 
142
162
    setContent(this.visContainer);
143
163
 
175
195
    visInput.setSingleResultPanelRef(parentPanel);
176
196
    visInput.setSegmentationName(segmentationName);
177
197
    visInput.setMediaIDs(mediaIDs);
178
 
    visInput.setMediaVisualizer(mediaVisualizer);    
 
198
    visInput.setMediaVisualizer(mediaVisualizer);
179
199
 
180
 
    compVis.setVisualizerInput(visInput);   
 
200
    compVis.setVisualizerInput(visInput);
181
201
    visContainer.addComponent(compVis, "compVis");
182
202
  }
183
203
 
240
260
    }
241
261
    catch (Exception e)
242
262
    {
243
 
      Logger.getLogger(VisualizerPanel.class.getName()).log(Level.SEVERE,
244
 
        "General remote service exception", e);
 
263
      log.error("General remote service exception", e);
245
264
    }
246
265
    return text;
247
266
  }
321
340
          String url = getApplication().getRelativeLocation(resource);
322
341
          iframe = new AutoHeightIFrame(url == null ? "/error.html" : url, this);
323
342
 
324
 
 
325
343
          visContainer.addComponent(iframe, "iframe");
326
344
        }
327
345