/// <summary>Creates new form ParserPanel</summary> public ParserPanel() { // constants for language specification // one second in milliseconds // parser takes approximately a minute to load // parser takes 5-60 seconds to parse a sentence // constants for finding nearest sentence boundary // for highlighting // worker threads to handle long operations // to monitor progress of long operations //private ProgressMonitor progressMonitor; // progress count // use glass pane to block input to components other than progressMonitor InitComponents(); // create dialogs for file selection jfc = new JFileChooser(Runtime.GetProperty("user.dir")); pageDialog = new OpenPageDialog(new Frame(), true); pageDialog.SetFileChooser(jfc); jfcLocation = new ParserPanel.JFileChooserLocation(jfc); tlp = new PennTreebankLanguagePack(); encoding = tlp.GetEncoding(); SetFont(); // create a timer timer = new Timer(OneSecond, new ParserPanel.TimerListener(this)); // for (un)highlighting text highlightStyle = new SimpleAttributeSet(); normalStyle = new SimpleAttributeSet(); StyleConstants.SetBackground(highlightStyle, Color.yellow); StyleConstants.SetBackground(normalStyle, textPane.GetBackground()); this.chooseJarParser = new JarFileChooser(".*\\.ser\\.gz", this); }
/// <summary>Highlights specified text region by changing the character attributes</summary> private void HighlightText(int start, int end, SimpleAttributeSet style) { if (start < end) { textPane.GetStyledDocument().SetCharacterAttributes(start, end - start + 1, style, false); } }
private IAttributeSet GetAttributeSet(string tag) { IMutableAttributeSet attr = new SimpleAttributeSet(); Color color = tagToColorMap[tag]; StyleConstants.SetBackground(attr, color); StyleConstants.SetForeground(attr, Color.White); return(attr); }
private void createAttributes() { attributes = new ConcurrentDictionary <Level, MutableAttributeSet>(); for (int i = 0; i < levels.Length; i++) { MutableAttributeSet att = new SimpleAttributeSet(); attributes[levels[i]] = att; StyleConstants.setFontSize(att, Settings.Instance.Font.Size); StyleConstants.setFontFamily(att, Settings.Instance.Font.Family); } StyleConstants.setForegRound(attributes[Level.FATAL], Color.red); StyleConstants.setForegRound(attributes[Level.ERROR], Color.red); StyleConstants.setForegRound(attributes[Level.WARN], Color.orange); StyleConstants.setForegRound(attributes[Level.INFO], Color.black); StyleConstants.setForegRound(attributes[Level.DEBUG], Color.gray); StyleConstants.setForegRound(attributes[Level.TRACE], Color.gray); }
private void RemoveTags() { if (editorPane.GetContentType().Equals("text/html")) { editorPane.SetText(htmlContents); editorPane.Revalidate(); editorPane.Repaint(); } else { DefaultStyledDocument doc = (DefaultStyledDocument)editorPane.GetDocument(); SimpleAttributeSet attr = new SimpleAttributeSet(); StyleConstants.SetForeground(attr, Color.Black); StyleConstants.SetBackground(attr, Color.White); doc.SetCharacterAttributes(0, doc.GetLength(), attr, false); } saveTaggedAs.SetEnabled(false); }