1
1
function applicationStarted ( pluginWorkspaceAccess ) {
2
- imageHandler = {
2
+ var imageHandler = {
3
3
editImage : function ( editContext ) { return null ; } ,
4
4
editImage : function ( url ) { return false ; } ,
5
5
canHandleFileType : function ( type ) { return type . equals ( "cgm" ) } ,
@@ -12,37 +12,44 @@ function applicationStarted(pluginWorkspaceAccess) {
12
12
return getCGMImage ( pluginWorkspaceAccess , cp , rc ) ;
13
13
}
14
14
}
15
- pluginWorkspaceAccess . getImageUtilities ( ) . addImageHandler ( new JavaAdapter ( Packages . ro . sync . exml . workspace . api . images . handlers . EditImageHandler , imageHandler ) ) ;
15
+
16
+
17
+ /**
18
+ * This line overrides the oXygen default CGM image handler.
19
+ *
20
+ * Uncomment to activate this feature.
21
+ */
22
+ //pluginWorkspaceAccess.getImageUtilities().addImageHandler(new JavaAdapter(Packages.ro.sync.exml.workspace.api.images.handlers.EditImageHandler, imageHandler));
16
23
}
17
24
18
25
function getCGMImage ( pluginWorkspaceAccess , cp , rc ) {
19
- cgmPanel = new Packages . net . sf . jcgm . core . CGMPanel ( ) ;
26
+ var cgmPanel = new Packages . net . sf . jcgm . core . CGMPanel ( ) ;
20
27
cgmPanel . setSize ( 800 , 600 ) ;
21
28
cgmPanel . open ( cp . getUrl ( ) ) ;
22
29
// Create a new bufferedImage with imagePanel size
23
- image = new Packages . java . awt . image . BufferedImage ( 800 , 600 , Packages . java . awt . image . BufferedImage . TYPE_INT_RGB ) ;
30
+ var image = new Packages . java . awt . image . BufferedImage ( 800 , 600 , Packages . java . awt . image . BufferedImage . TYPE_INT_RGB ) ;
24
31
// Create a graphics context from the new image
25
- graphics = image . createGraphics ( ) ;
32
+ var graphics = image . createGraphics ( ) ;
26
33
graphics . setColor ( Packages . java . awt . Color . WHITE ) ;
27
34
graphics . fillRect ( 0 , 0 , 800 , 600 ) ;
28
-
29
- paintComponentMethod = getPaintMethod ( cgmPanel . getClass ( ) ) ;
35
+
36
+ var paintComponentMethod = getPaintMethod ( cgmPanel . getClass ( ) ) ;
30
37
paintComponentMethod . setAccessible ( true ) ;
31
38
paintComponentMethod . invoke ( cgmPanel , graphics ) ;
32
39
return image ;
33
40
}
34
41
35
42
/**
36
43
* Looks inside the provided class to find the "paint" method.
37
- *
38
- * @param clazz The class with public "paint" method.
44
+ *
45
+ * @param clazz The class with public "paint" method.
39
46
* @return The "paint" method.
40
47
*/
41
48
function getPaintMethod ( clazz ) {
42
- paint = null ;
49
+ var paint = null ;
43
50
while ( paint == null && clazz != null ) {
44
51
try {
45
- declMethods = clazz . getDeclaredMethods ( ) ;
52
+ var declMethods = clazz . getDeclaredMethods ( ) ;
46
53
for ( i = 0 ; i < declMethods . length ; i ++ ) {
47
54
if ( declMethods [ i ] . getName ( ) . equals ( "paint" ) ) {
48
55
paint = declMethods [ i ] ;
@@ -51,10 +58,10 @@ function getCGMImage(pluginWorkspaceAccess, cp, rc){
51
58
} catch ( e ) {
52
59
// No such method.
53
60
}
54
-
61
+
55
62
clazz = clazz . getSuperclass ( ) ;
56
63
}
57
-
64
+
58
65
return paint ;
59
66
}
60
67
0 commit comments