author | wenzelm |
Tue, 20 Jan 2009 18:23:40 +0100 | |
changeset 34489 | 7b7ccf0ff629 |
parent 34456 | 14367c0715e8 |
child 34552 | 65f1b2261cc6 |
permissions | -rw-r--r-- |
34408 | 1 |
/* |
2 |
* Dockable window with rendered state output |
|
3 |
* |
|
4 |
* @author Fabian Immler, TU Munich |
|
5 |
* @author Johannes Hölzl, TU Munich |
|
6 |
*/ |
|
7 |
||
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
8 |
package isabelle.jedit |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
9 |
|
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
10 |
|
34424 | 11 |
import java.awt.{BorderLayout, Dimension} |
12 |
import javax.swing.{JButton, JPanel, JScrollPane} |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
13 |
|
34438 | 14 |
import isabelle.renderer.UserAgent |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
15 |
|
34428
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
16 |
import org.xhtmlrenderer.simple.{XHTMLPanel, FSScrollPane} |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
17 |
import org.xhtmlrenderer.context.AWTFontResolver |
34428
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
18 |
import org.xhtmlrenderer.layout.SharedContext; |
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
19 |
import org.xhtmlrenderer.extend.TextRenderer; |
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
20 |
import org.xhtmlrenderer.swing.Java2DTextRenderer; |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
21 |
|
34428
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
22 |
import org.gjt.sp.jedit.jEdit |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
23 |
import org.gjt.sp.jedit.View |
34424 | 24 |
import org.gjt.sp.jedit.gui.DockableWindowManager |
34428
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
25 |
import org.gjt.sp.jedit.textarea.AntiAlias |
34424 | 26 |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
27 |
|
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
28 |
class StateViewDockable(view : View, position : String) extends JPanel { |
34424 | 29 |
|
34428
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
30 |
// outer panel |
34424 | 31 |
if (position == DockableWindowManager.FLOATING) |
32 |
setPreferredSize(new Dimension(500, 250)) |
|
34406
f81cd75ae331
restructured: independent provers in different buffers
immler@in.tum.de
parents:
34397
diff
changeset
|
33 |
setLayout(new BorderLayout) |
f81cd75ae331
restructured: independent provers in different buffers
immler@in.tum.de
parents:
34397
diff
changeset
|
34 |
|
34428
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
35 |
|
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
36 |
// XHTML panel |
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
37 |
val panel = new XHTMLPanel(new UserAgent) |
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
38 |
|
34361 | 39 |
|
34428
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
40 |
// anti-aliasing |
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
41 |
// TODO: proper EditBus event handling |
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
42 |
{ |
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
43 |
val aa = jEdit.getProperty("view.antiAlias") |
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
44 |
if (aa != null && aa != AntiAlias.NONE) { |
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
45 |
panel.getSharedContext.setTextRenderer( |
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
46 |
{ |
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
47 |
val renderer = new Java2DTextRenderer |
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
48 |
renderer.setSmoothingThreshold(0) |
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
49 |
renderer.setSmoothingLevel(TextRenderer.HIGH) |
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
50 |
renderer |
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
51 |
}) |
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
52 |
} |
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
53 |
} |
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
54 |
|
34434 | 55 |
|
34428
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
56 |
// copy & paste |
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
57 |
(new SelectionActions).install(panel) |
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
58 |
|
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
59 |
|
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
60 |
// scrolling |
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
61 |
add(new FSScrollPane(panel), BorderLayout.CENTER) |
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
62 |
|
34361 | 63 |
|
34406
f81cd75ae331
restructured: independent provers in different buffers
immler@in.tum.de
parents:
34397
diff
changeset
|
64 |
private val fontResolver = |
f81cd75ae331
restructured: independent provers in different buffers
immler@in.tum.de
parents:
34397
diff
changeset
|
65 |
panel.getSharedContext.getFontResolver.asInstanceOf[AWTFontResolver] |
34440 | 66 |
if (Isabelle.plugin.font != null) |
67 |
fontResolver.setFontMapping("Isabelle", Isabelle.plugin.font) |
|
34406
f81cd75ae331
restructured: independent provers in different buffers
immler@in.tum.de
parents:
34397
diff
changeset
|
68 |
|
34456 | 69 |
Isabelle.plugin.font_changed += (font => { |
34440 | 70 |
if (Isabelle.plugin.font != null) |
71 |
fontResolver.setFontMapping("Isabelle", Isabelle.plugin.font) |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
72 |
|
34406
f81cd75ae331
restructured: independent provers in different buffers
immler@in.tum.de
parents:
34397
diff
changeset
|
73 |
panel.relayout() |
f81cd75ae331
restructured: independent provers in different buffers
immler@in.tum.de
parents:
34397
diff
changeset
|
74 |
}) |
f81cd75ae331
restructured: independent provers in different buffers
immler@in.tum.de
parents:
34397
diff
changeset
|
75 |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
76 |
} |