Subversion Repositories general

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
240 swalkenh 1
PK
813 swalkenh 2
 
3
 
4
Class-Path: ImagePlugin.jar
240 swalkenh 5
Transform-To-File: src/plugins/regionEditorPlugin/RegionEditorPluginTr
6
 ansform.xsl
813 swalkenh 7
XMLEditor-Plugin-Name: RegionEditor
8
Created-By: 1.4.2 (Sun Microsystems Inc.)
9
Main-Class: src.plugins.regionEditorPlugin.RegionEditorPlugin
240 swalkenh 10
Description: ...(todo)
11
Transform-Fro-File: src/plugins/regionEditorPlugin/RegionEditorPluginT
260 swalkenh 12
 ransformBack.xsl
813 swalkenh 13
Comment: you can set named regions on pictures
240 swalkenh 14
 
15
Name: src/plugins/regionEditorPlugin
813 swalkenh 16
Specification-Title: plugin for XMLEditor
17
Implementation-Title: src.plugins.regionEditorPlugin
240 swalkenh 18
Specification-Version: 0.4 (05/07/03)
813 swalkenh 19
Specification-Vendor: group5, software practice SS_2003, University Bi
20
 elefeld, Germany
240 swalkenh 21
Implementation-Version: 0.1 (05/07/03)
22
Implementation-Vendor: group5, software practice SS_2003, University B
23
 ielefeld, Germany
24
 
25
PK
813 swalkenh 26
 
746 swalkenh 27
imageWidthimageHeightcoefDregionsLjava/util/List;selectedRegion'Lsrc/plugins/regionEditorPlugin/Region;<init>(Ljava/util/List;)VCode(Z)V
28
 
29
 
30
 
31
*-java/awt/Graphics/setColor(Ljava/awt/Color;)V12
32
 
33
 
34
 
35
 
36
 
37
 
38
 
39
 
40
 
41
injava/awt/RectanglepgetX()Drs
42
 
43
 
44
 
45
 
46
 
47
 
48
 
49
 
50
Cº
~*¶%=*¶(>+*¶.¶4+¶8*´:Æ_*´:¶?6*´:¶A6‡‡o9‡‡o9*¸GµI*´I˜œ*µI§‡*´IoŽ6‡*´IoŽ6*dlµK*dlµM*µO*µQ+*´:*´K*´M¶UW+²[¶4+²^¶a6
51
§`*´
52
 
53
 
54
 
55
 
56
¶u*´IoŽ*´K`
57
¶x*´IoŽ*´M`
58
¶z*´IoŽ
59
¶|*´IoŽ¶±ª*KL
60
OPS!V+W5X=YE[P]Y^a`lawde‹f‘g—j­m´n»oÁpÑrÚsáuâvòwx
yuo,~3<€CD‚Tƒd„o…z}ˆz~~†‡yˆ
61
t‰+RŠ5H‹=@Œ
E8
¾nŽ
62
ÑJá:‘<A‘
63
’“F
64
*+µ:*¶—±‘	’
65
 
66
 
67
ÍΏŸ PK
68
 
69
 
70
 
71
 
72
 * University of Bielefeld, Germany
73
 
813 swalkenh 74
 
75
 
76
 
746 swalkenh 77
 * $Id: ImagePanel.java,v 1.8 2003/07/24 13:34:43 hjokusch Exp $
78
 */
79
80
package src.plugins.regionEditorPlugin;
81
813 swalkenh 82
import java.util.List;
746 swalkenh 83
813 swalkenh 84
import java.awt.Color;
85
import java.awt.Rectangle;
746 swalkenh 86
import java.awt.Graphics;
87
 
88
89
 
90
91
 
92
 * Image panel shows any image.
93
 *
94
 * @author Yulia Klassen, Viktoriya Zudova
95
 *
96
 
97
 */
98
 
99
100
	/** The current image. */
101
	private Image image;
813 swalkenh 102
746 swalkenh 103
	/** The dx-shift of an image in relation to the left top corner of plugin panel. */
813 swalkenh 104
	private int dx;
746 swalkenh 105
106
	/** The dy-shift of an image in realtion to the left top corner of plugin panel. */
107
 
813 swalkenh 108
746 swalkenh 109
	/** The width of the image. */
110
 
813 swalkenh 111
746 swalkenh 112
	/** The height of the image. */
113
 
813 swalkenh 114
746 swalkenh 115
116
 
813 swalkenh 117
	private double coef;
746 swalkenh 118
	
119
 
813 swalkenh 120
	private List regions;
746 swalkenh 121
	
122
 
813 swalkenh 123
 
124
746 swalkenh 125
	/**
126
 
813 swalkenh 127
	 * all elements for the options dialog.
746 swalkenh 128
	 *
129
 
813 swalkenh 130
	 */
746 swalkenh 131
	public ImagePanel(List regions) {
132
 
133
		this.regions = regions;
134
	}
135
136
	/**
137
	 * <code>paintComponent</code> draws the image.
138
	 *
139
	 * @see javax.swing.JComponent#paintComponent
140
	 */
141
	public void paintComponent(Graphics g) {
142
		int w  = getWidth();
143
 
144
145
		/* Fill the background. */
146
		g.setColor(getBackground());
147
		g.fillRect(0, 0, w, h);
148
149
		/* If there is an image ... */
150
		if(image != null) {
151
152
 
153
	  		int iw = image.getWidth(null);
154
	  		int ih = image.getHeight(null);
155
	  		double kx = (double)iw/w;
156
 
157
158
	 		coef = Math.max(kx, ky);
159
 
160
      	  	if(coef < 1) {
161
      			coef = 1;
162
      	  	} else {
163
      			iw = (int)(iw/coef);
164
      			ih = (int)(ih/coef);
165
 
166
167
 
168
      	  	dy = (h-ih)/2;
169
      	  	imageWidth = iw;
170
      	  	imageHeight = ih;
171
172
      	  	/* Draw the image. */
173
      	  	g.drawImage(image, dx, dy, iw, ih, null);
174
 
175
      	  	/* Draw regions. */
176
      	  	g.setColor(Color.black);
177
      	  	g.setXORMode(Color.white);
178
      	  	for(int i = 0; i < regions.size(); i++) {
179
 
180
181
      			if(region != selectedRegion){           // The selected one will be drawn later.
182
 
183
184
      				g.drawRect(
185
        				(int)(rect.getX() / coef) + dx,
186
        				(int)(rect.getY() / coef) + dy,
187
        				(int)(rect.getWidth() / coef),
188
 
813 swalkenh 189
      			}
746 swalkenh 190
	  		}
191
 
192
	  		/* Draw the selected rectangle. */
193
	  		if(selectedRegion != null) {
194
   			    Rectangle rect = selectedRegion.getRect();
195
				g.setColor(Color.red);
196
				g.drawRect(
197
    			  	(int)(rect.getX() / coef) + dx,
198
    			  	(int)(rect.getY() / coef) + dy,
199
 
200
    			  	(int)(rect.getHeight() / coef));
201
	  		}
202
		}
203
	}
204
205
  	/**
206
  	 * Sets the currently visible image to the image given as parameter.
207
  	 *
208
  	 * @param image: The image to display.
209
  	 */
210
  	public void setImage(Image image) {
211
		this.image = image;
212
 
213
	}
214
215
216
	/**
217
	 * The methode <code> getCoef </code> retuns the double for 
218
	 * scaling the image
219
	 * 
220
	 * @return coef double: the scale (coefficient) for the Image
221
	 */
222
 
813 swalkenh 223
 
224
	}
225
226
  	/**
227
  	 * Returns the dx-shift of an image according to the left top
228
  	 * corner of the plugin panel.
229
  	 *
746 swalkenh 230
  	 * @return The difference on the x-axis.
231
  	 */
232
	public int getDx() {
233
 
234
	}
235
236
    /**
237
     * Returns the dy-shift of an image according to the left top
238
     * corner of the plugin panel.
239
     *
240
     * @return The difference on the y-axis.
241
     */
242
	public int getDy() {
243
 
244
	}
245
246
    /**
247
     * Returns the width of the current image.
248
     *
249
     * @return The width of the current image.
250
     */
251
	public int getImageWidth() {
252
		return imageWidth;
253
 
254
255
	/**
256
	 * Returns the height of the current image.
257
	 *
258
	 * @return The height of the current image.
259
	 */
260
	public int getImageHeight() {
261
		return imageHeight;
262
 
263
264
265
	/**
266
	 * The method<code>setSelectedRegion</code> Returns the current selected region in the Image
267
	 * The Region represenrs a specified arey in the picture with a specified name.
268
	 * 
269
	 * @param region the selected src.plugins.regionEditorPlugin.Region
270
	 */ 
271
 
813 swalkenh 272
 
273
	}
274
}PK
275
A‰ù.154_™™+src/plugins/regionEditorPlugin/Region.classÊþº¾-&%src/plugins/regionEditorPlugin/Regionjava/lang/ObjectnameLjava/lang/String;rectLjava/awt/Rectangle;savedNameOfNode<init>()VCode
276

277

LineNumberTableLocalVariableTablethis'Lsrc/plugins/regionEditorPlugin/Region;)(Ljava/lang/String;Ljava/awt/Rectangle;)V		getName()Ljava/lang/String;setName(Ljava/lang/String;)VgetRect()Ljava/awt/Rectangle;setRect(Ljava/awt/Rectangle;)VgetSavedNameOfNode		!setSavedNameOfNode
278
SourceFileRegion.java!	
746 swalkenh 279
3*·±
280
#%
281
Y*·*+µ*,µ±,.	/0 /*´°8>*+µ±
282
AB/*´°J>*+µ±
813 swalkenh 283
 
284
 
285
 
286
 * This file contains the Region class.
287
 *
288
 
289
 
290
 
291
 
292
 
293
 
294
 
746 swalkenh 295
 */
296
297
package src.plugins.regionEditorPlugin;
298
299
import java.awt.Rectangle;
813 swalkenh 300
//import org.w3c.dom.Node;
746 swalkenh 301
813 swalkenh 302
/**
303
 * Stores info of one region.
746 swalkenh 304
 *
305
 
306
 */
307
 
308
{
309
  /** Stores name of region.*/
310
 
311
312
  /** Stores coordinates of region. */
313
  private Rectangle rect;
314
315
  /** Stores name of node for the region.*/
316
  private String savedNameOfNode;
317
813 swalkenh 318
  /** Creates empty region with coordinates and name. */
746 swalkenh 319
  public Region()
320
 
813 swalkenh 321
  }
746 swalkenh 322
323
 
813 swalkenh 324
   *
325
   * @param name: Region name.
326
 
327
   */
746 swalkenh 328
  public Region(String name, Rectangle rect)
329
  {
330
	this.name = name;
331
 
813 swalkenh 332
  }
333
334
  /** Returns the name of the region.
335
   *
336
   * @return the name of the region.
746 swalkenh 337
   */
338
  public String getName()
339
  {
340
	return name;
341
  }
342
 
813 swalkenh 343
  /** Sets the name of the region.
344
   *
345
   * @param name:  The name of the region.
346
   */
746 swalkenh 347
  public void setName(String name)
348
  {
349
	this.name = name;
350
  }
351
 
813 swalkenh 352
  /** Returns the coordinates of the region.
353
   *
354
   * @return the coordinates of the region.
355
   */
746 swalkenh 356
  public Rectangle getRect()
357
  {
358
	return rect;
359
  }
360
 
813 swalkenh 361
  /** Sets the coordinates of the region.
362
   *
363
   * @param rect: The coordinates of the region.
364
   */
746 swalkenh 365
  public void setRect(Rectangle rect)
366
  {
367
	this.rect = rect;
368
  }
369
 
813 swalkenh 370
  /** Returns the saved name of node for the region.
371
   *
372
   * @return the saved name of node for the region.
373
   */
746 swalkenh 374
  public String getSavedNameOfNode()
375
  {
376
	return savedNameOfNode;
377
  }
813 swalkenh 378
 
379
  /** Sets the saved name of node for the region.
380
   *
381
   * @param name:  The saved name of node for the region.
382
   */
383
  public void setSavedNameOfNode(String name)
384
  {
385
	this.savedNameOfNode = name;
386
  }
387
 
388
PK
389
çù.[èÿ\A\A7src/plugins/regionEditorPlugin/RegionEditorPlugin.classÊþº¾-ÿ1src/plugins/regionEditorPlugin/RegionEditorPluginjavax/swing/JPanelsrc/plugins/PluginInterfacejava/awt/event/ActionListener"java/awt/event/MouseMotionListener	java/awt/event/MouseListener
390
pluginNameLjava/lang/String;
ConstantValueRegionEditorimageLjava/awt/Image;imageNameLabelLjavax/swing/JLabel;imageNameFieldLjavax/swing/JTextField;
confirmButtonLjavax/swing/JButton;regionNameLabelregionNameFieldregionConfirmButton
391
imagePanel+Lsrc/plugins/regionEditorPlugin/ImagePanel;guiLsrc/gui/GuiInterface;ourEventListenerLsrc/control/OurEventListener;	imageNameimageUrlcurrentFileLjava/io/File;oldNodeLorg/w3c/dom/Node;changedNodeenvironmentLorg/w3c/dom/Document;regionsLjava/util/List;selectedRegion'Lsrc/plugins/regionEditorPlugin/Region;normalCursorLjava/awt/Cursor;
392
moveCursorresizeCursorinMoveZinResizepopupLjavax/swing/JPopupMenu;deleteSelectedItemLjavax/swing/JMenuItem;<init>()VCode;<
393
>
	@javax/swing/JLabelB Image Name D(Ljava/lang/String;)V;F
394
CG	Ijavax/swing/JTextFieldK
395
L>	Njavax/swing/JButtonPConfirmR
746 swalkenh 396
QG	U
 Region Name W	Y	[	]java/util/ArrayList_
397
`>,-	bjava/awt/Cursord(I)V;f
813 swalkenh 398
 
521 swalkenh 399
t>78	vjavax/swing/JMenuItemxDelete the regionz
813 swalkenh 400
yG9:	}java/awt/BorderLayout
401
€>java/awt/Container‚	setLayout(Ljava/awt/LayoutManager;)V„…
402
ƒ†)src/plugins/regionEditorPlugin/ImagePanelˆ(Ljava/util/List;)V;Š
403
‰‹	java/awt/ComponentaddMouseListener!(Ljava/awt/event/MouseListener;)V‘’
404
 
405
 
406
 
407
 
408
 
409
ª­North¯javax/swing/AbstractButton±addActionListener"(Ljava/awt/event/ActionListener;)V³´
410
 
411
 
412
 
413
 
414
 
415
 
416
 
417
 
418
 
419
 
420
 
421
 
422
 
423
 
424
 
425
ILtransformsNode8(Ljava/lang/String;Lorg/w3c/dom/Node;)Lorg/w3c/dom/Node;NOAPnameRurlT
getChildNodes()Lorg/w3c/dom/NodeList;VWåXorg/w3c/dom/NodeListZitem(I)Lorg/w3c/dom/Node;\][^	getLength()I`a[bmanager$Lsrc/plugins/PluginManagerInterface;associatedPlugintransformedNodenodeAttrLorg/w3c/dom/NamedNodeMap;listLorg/w3c/dom/NodeList;iIjava/util/Listnclearp<oq	RECTANGLEsCOORDSuXMLEditorSavedNameOfNodewxyjava/lang/Integer{parseInt(Ljava/lang/String;)I}~
426
 
427
IŠŒ%src/plugins/regionEditorPlugin/RegionŽjava/awt/Rectangle(IIII)V;’
428
‘“)(Ljava/lang/String;Ljava/awt/Rectangle;)V;•
429
–setSavedNameOfNode˜F
430
 
431
 
432
 
433
IÀ:Âì^="Åìb [È]Ê¶<
434
µÌª«
435
 
436
ðcreateTextNode&(Ljava/lang/String;)Lorg/w3c/dom/Text;òóô
createElement)(Ljava/lang/String;)Lorg/w3c/dom/Element;ö÷øgetSavedNameOfNodeúò
437
ûsetAttribute'(Ljava/lang/String;Ljava/lang/String;)Výþ<ÿgetRect()Ljava/awt/Rectangle;
438
ym	‘(I)Ljava/lang/String;/
439
 
440
widthm	‘
heightm	‘appendChild&(Lorg/w3c/dom/Node;)Lorg/w3c/dom/Node;åhasNext()ZêfirePluginChangedElement'(Lorg/w3c/dom/Node;Lorg/w3c/dom/Node;)V
441
tempDocLjava/util/Iterator;Lorg/w3c/dom/Text;geomLorg/w3c/dom/Element;coordssrc/control/OurEvent$java/lang/Object&([Ljava/lang/Object;)V;(
442
%)src/control/OurEventListener+
firedOurEvent(Lsrc/control/OurEvent;)V-.,/eLsrc/control/OurEvent;%&	3	5No image7getCurrentFile()Ljava/io/File;9:Ñ;java/io/File=
getParentFile?:
443
>@
444
>0
445
startsWith(Ljava/lang/String;)ZCD
446
IE/GreplaceFirst8(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;IJ
447
IKcharAt(I)CMN
448
IO
449
>G#(Ljava/io/File;Ljava/lang/String;)V;R
450
>Sjavax/imageio/ImageIOUread.(Ljava/io/File;)Ljava/awt/image/BufferedImage;WX
451
 
452
‰ajava/io/IOExceptioncfileNamedocLjava/io/IOException;actionPerformed(Ljava/awt/event/ActionEvent;)Vjava/util/EventObjectj	getSourcelì
453
kmgetTextoò
454
öp×<
455
r./	tsetNamevF
456
wdeleteRegion*(Lsrc/plugins/regionEditorPlugin/Region;)Vyz
457
{Ljava/awt/event/ActionEvent;mouseDragged(Ljava/awt/event/MouseEvent;)Vjava/awt/event/MouseEvent€getX‚a
458
ƒgetY…a
459
 
460
‰getDx‹a
461
‰ŒgetCoef()DŽ
462
‰getDy’a
463
‰“getWidth•
464
‘–java/awt/Image˜!(Ljava/awt/image/ImageObserver;)I•š
465
™›	getHeight
466
‘žš
467
™ setLocation¢¦
468
‘£repaint¥<
469
¦‚
470
‘¨…
471
‘ªsetSize¬¦
472
 
473
°	addRegion²z
474
 
475
 
476
findRegion,(IIZ)Lsrc/plugins/regionEditorPlugin/Region;º»
477
 
478
Àregion1region2
getImageWidthÄa
479
‰ÅgetImageHeightÇa
480
 
481
 
482
 
483
 
484
Ú
mouseReleasedmouseEnteredmouseExitedremoveßKoàget(I)Ljava/lang/Object;âãoäcontains(II)Zæç
485
‘èsizeêaoëjava/lang/Mathíabs(I)Iïð
486
îñnordWest
currentRegion
487
setEnabledõ»
488
yöshow(Ljava/awt/Component;II)Vøù
489
 
490
‰°
491
SourceFileRegionEditorPlugin.java!
492

 !"#$%&'()(*+,-./0121314565789:;<=Šš*·?*µA*»CYE·HµJ*»LY·MµO*»QYS·TµV*»CYX·HµZ*»LY·Mµ\*»QYS·Tµ^*»`Y·aµc*»eY·hµj*»eY
·hµl*»eY·hµn*µp*µr*»tY·uµw*»yY{·|µ~*»€Y·¶‡*»‰Y*´c·ŒµŽ*´Ž*¶”*´Ž*¶˜»Y·?L+»€Y·¶‡+*´Jš¶ž+*´O¶¡W+*´V£¶ž»Y·?M,»¥Y𷨶®,»€Y·¶‡,*´Zš¶ž,*´\¶¡W,*´^£¶ž»Y·?N-»€Y·¶‡-+¶¡W-,£¶ž*-°¶ž**´Ž¶¡W*´V*¶¶*´^*¶¶*´~*¶¶*´w*´~¶¹W*¶½±¾®+–H
493
 
494
 
746 swalkenh 495
ÚÛ(Ü7Þ;ßCáYãdähçméwê|ë¿*}ÀÁ}(}*+}ú<=°b***´É¹¹*´ã*´Í¹·µ*´Ç2*´É¹!»#Y%·&*´ã¶*,¶*.¶*¶1¹7**´·:±¾*
813 swalkenh 496
òòóô#ö*÷4øT÷Yûaü¿bÀÁ=€	°-Á<š°+-¹?¹E:Æ_G¶M™T+-¹Q:ÆD¹é:S¹ð¹ô:U¹ð¹ô:Æ,¶M™Æ°-¹Y:6§*+,¹_·:Æ°„¹c¡ÿÛ°¾>
497
 
498
 
499
„¹c¡ÿ<»Y
500
 
501
 
502
—˜¿ÀÁÖ"×<=â$**´Ï¹ÛµÝ*´Ï¹áL*´ݹéê¹ð*´ã¹ä**´Ï·Ï*´c¹èM§Á,¹îÀN+-¶ñ¹õ:+t¹ù:+v¹ù:-¶üÆ-¶ü¥x-¶ü¹z-¶´¸	¹‚-¶´¸	¹„-¶´¸	¹†-¶´¸	¹¹W¹W*´ÝÀå¹W,¹šÿ<**´Ý·Ï**´Ï*´Ý·±¾^žŸ 1¢:£D¤G¥Q¦]§h¨s®„¯’²¦³º´Îµâ¶ì·ö¸¤º¼#½¿H$ÀÁ+DàlQ´©/]¨R h!"s’#"=t$»%Y½'Y+SY,SYS·*N*´Õ-¹0±¾ÆÇ#È¿*$ÀÁ$'($)(128F=Ï+*µ4+Ç+*µ6*´É¹Õ¹Ú*´É¹Õ8¹Ý§ñ*´É¹<M+,¶A¶B¶F™%+»#Y,¶A¶B¸Á·&H¶*¶1¶LL+¶P/ *»>Y+·Qµ4§*»>Y,¶A+·Tµ4**´4¸Zµ6*´É¹Õ¹Ú*´É¹Õ»#Y\·&+¶*¶1¹Ý§RM*´É¹!»#Y^·&+¶*¶1¹7*´É¹Õ¹Ú*´É¹Õ»#Y^·&+¶*¶1¹Ý*´Ž*´6¶b±1ÐÐd¾ZÒÕ	Ö×Ø1Ý;ÞIßkâuã„å”èŸé®êÐìÑíÚîìíñïðô*õ¿*+ÀÁ+e;•f&ÑN¦ghi=ºZ+¶n*´V¦**´O¶qµã*¶s*·ü+¶n*´^¦*´uÆ*´u*´\¶q¶x*¶s+¶n*´~¦**´u¶|*¶s±¾2þÿ)0>BMU
Y¿ZÀÁZ1}~=}
503
 
504
VWY,[0\;_IaMbXe`i¿*aÀÁa1µ,4Â/IÃ/ˆ¦=|*´Ž¶d>*´Ž¶”d6››*´Ž¶Æ£*´Ž¶ɤ*´É¹Õ¹á§7‡*´Ž¶‘kŽ6‡*´Ž¶‘kŽ6*´É¹Õ»ËY·̹á±¾&	s
505
 
506
rymgmT'ÏmbÐmÑ=c#+¶n*´Ž¦*´6Æ*+¶„+¶‡·Ô*¶§±¾Š‹Œ"Ž¿#ÀÁ#1µÕ=ÿ+¶n*´Ž¦v*´6Æo+¶ؙ*+¶„+¶‡·Û§Y*+¶„+¶‡·½M,Æ**´l¶Á*,·±*µp§2*+¶„+¶‡·½N-Æ**´n¶Á*-·±*µr§**´j¶Á±¾>—˜™(œ6ž:ŸB G¡O¤]¦a§i¨n©v¬~±¿*ÀÁ1µ6HÂ/]!Ã/Ü=’B+¶n*´Ž¦9*´6Æ2+¶ؙ*+¶„+¶‡·Û*´pš
507
*´r™*¶s*µp*µr±¾"¼½¾%Â3Ã7Å<ÆAÈ¿BÀÁB1µÝ=5±¾пÀÁ1µÞ=W+¶n*´Ž¦*´É¹Õ¹á±¾ÛÜÞ¿ÀÁ1µ²z=L*´c+¹œW*¶§±¾çèé¿ÀÁ©/yz=]*´u+¦*·±*´c+¹áW*¶§±¾ò
óôõ¿ÀÁ©/Ò¦=÷m*´Ž¶d‡*´Ž¶‘kŽ>*´Ž¶”d‡*´Ž¶‘kŽ6*·±6§-*´c¹åÀ:¶¶é™*·±§„*´c¹ì¡ÿ˱¾*
508
ÿ).4DRX	[l¿HmÀÁmymmmYÏm)DÐm1;lmD©/º»=…
746 swalkenh 509
Á*´Ž¶d‡*´Ž¶‘kŽ6*´Ž¶”d‡*´Ž¶‘kŽ6:6§€*´c¹åÀ:¶:	™-	¶©Žd¸ò¢R	¶«Žd¸ò¢B:§L§8	¶©Ž	¶—Ž`d¸ò¢!	¶«Ž	¶ŸŽ`d¸ò¢
813 swalkenh 510
:§„*´c¹ì¡ÿx°¾F*-3 C!J#N$^%n'r(x,-¦/ª0­¾5¿f
511
 
512
 
513
 
746 swalkenh 514
 * This file contains the RegionEditorPlugin class.
813 swalkenh 515
 
516
 
517
 * University of Bielefeld, Germany
518
 
519
 
520
 
521
 
522
 
523
 */
746 swalkenh 524
813 swalkenh 525
package src.plugins.regionEditorPlugin;
526
527
import java.util.ArrayList;
528
import java.util.List;
529
import java.util.Iterator;
530
531
 
532
 
533
import java.awt.Dimension;
534
import java.awt.Image;
535
 
536
 
537
 
538
 
539
 
540
import java.awt.event.MouseEvent;
541
 
542
import java.awt.event.MouseMotionListener;
543
544
 
545
 
546
547
 
548
import javax.swing.JPopupMenu;
549
550
 
521 swalkenh 551
import org.w3c.dom.NamedNodeMap;
746 swalkenh 552
import org.w3c.dom.Document;
521 swalkenh 553
import org.w3c.dom.Element;
554
import org.w3c.dom.Node;
555
import org.w3c.dom.Text;
813 swalkenh 556
746 swalkenh 557
import javax.swing.JButton;
813 swalkenh 558
import javax.swing.JLabel;
559
import javax.swing.JPanel;
521 swalkenh 560
import javax.swing.JTextField;
561
 
562
563
 
746 swalkenh 564
import src.control.OurEvent;
565
import src.control.OurEventListener;
813 swalkenh 566
import src.gui.*;
746 swalkenh 567
 
521 swalkenh 568
import src.plugins.PluginManagerInterface;
746 swalkenh 569
570
571
572
/**
573
 * The <code>RegionEditor</code> plugin shows and edits image regions.
521 swalkenh 574
 
746 swalkenh 575
 * @author Yulia Klassen, Viktoriya Zudova
576
 *
577
 * @version $Revision: 1.28 $ Last modification: $Date: 2003/07/24 22:18:06 $
578
 */
579
public class RegionEditorPlugin
521 swalkenh 580
 
746 swalkenh 581
  implements PluginInterface, ActionListener, MouseMotionListener, MouseListener
582
{
583
 
584
  final private String pluginName = "RegionEditor";
585
586
 
587
  private Image image;
588
521 swalkenh 589
  /** Label where the name of image is. */
813 swalkenh 590
  private JLabel imageNameLabel = new JLabel(" Image Name ");
521 swalkenh 591
813 swalkenh 592
  /** A text field to enter the name of an image. */
521 swalkenh 593
 
746 swalkenh 594
813 swalkenh 595
  /** A button "Confirm" to change the image name in the node. */
746 swalkenh 596
  private JButton confirmButton = new JButton("Confirm");
597
598
  /** Label where the name of region is. */
599
 
600
 
521 swalkenh 601
  /** A text field to enter the name of region. */
602
  private JTextField regionNameField = new JTextField();
603
604
  /** A button "Confirm" to change the region name. */
813 swalkenh 605
  private JButton regionConfirmButton = new JButton("Confirm");
521 swalkenh 606
 
746 swalkenh 607
 
813 swalkenh 608
 
521 swalkenh 609
746 swalkenh 610
  /** Stores a reference to the GUI. */
611
  private GuiInterface gui;
612
613
  /** Stores a reference to the event listener. */
813 swalkenh 614
  private OurEventListener ourEventListener;
521 swalkenh 615
746 swalkenh 616
  /** The image's name from the attributes of the selected node. */
617
  private String imageName;
618
619
  /** The location of the image. */
620
  private String imageUrl;
621
521 swalkenh 622
 
813 swalkenh 623
  private File currentFile;
746 swalkenh 624
521 swalkenh 625
 
813 swalkenh 626
  private Node oldNode;
627
628
 
629
  private Node changedNode;
746 swalkenh 630
521 swalkenh 631
 
813 swalkenh 632
  private Document environment;
746 swalkenh 633
634
 
813 swalkenh 635
  private List regions = new ArrayList();
636
637
 
638
  private Region selectedRegion;
746 swalkenh 639
640
 
813 swalkenh 641
  private Cursor normalCursor = new Cursor(Cursor.DEFAULT_CURSOR);
746 swalkenh 642
643
 
813 swalkenh 644
  private Cursor moveCursor = new Cursor(Cursor.MOVE_CURSOR);
746 swalkenh 645
646
 
813 swalkenh 647
  private Cursor resizeCursor = new Cursor(Cursor.SE_RESIZE_CURSOR);
746 swalkenh 648
649
 
813 swalkenh 650
  private boolean inMove = false;
746 swalkenh 651
652
 
813 swalkenh 653
  private boolean inResize = false;
746 swalkenh 654
655
 
813 swalkenh 656
  private JPopupMenu popup = new JPopupMenu();
746 swalkenh 657
658
 
813 swalkenh 659
  private JMenuItem deleteSelectedItem = new JMenuItem("Delete the region");
746 swalkenh 660
661
 
813 swalkenh 662
  public RegionEditorPlugin() {
746 swalkenh 663
664
 
813 swalkenh 665
    setLayout(new BorderLayout());
746 swalkenh 666
667
 
813 swalkenh 668
    imagePanel = new ImagePanel(regions);
669
    imagePanel.addMouseListener(this);
670
 
671
746 swalkenh 672
    // Left panel: text field to enter name of image.
673
 
813 swalkenh 674
    leftPanel.setLayout(new BorderLayout());
746 swalkenh 675
	leftPanel.add(imageNameLabel, BorderLayout.WEST);
676
 
813 swalkenh 677
    leftPanel.add(confirmButton, BorderLayout.EAST);
746 swalkenh 678
679
 
813 swalkenh 680
    JPanel rightPanel = new JPanel();
746 swalkenh 681
    rightPanel.setPreferredSize(new Dimension(240, 24));
682
 
813 swalkenh 683
	rightPanel.add(regionNameLabel, BorderLayout.WEST);
746 swalkenh 684
    rightPanel.add(regionNameField);
685
 
813 swalkenh 686
746 swalkenh 687
    // Top panel contains left and right panels.
688
 
813 swalkenh 689
    topPanel.setLayout(new BorderLayout());
746 swalkenh 690
    topPanel.add(leftPanel);
691
 
813 swalkenh 692
746 swalkenh 693
    add(topPanel, BorderLayout.NORTH);
694
 
813 swalkenh 695
746 swalkenh 696
    confirmButton.addActionListener(this);
697
 
698
699
    // Init popup menu.
700
 
701
    popup.add(deleteSelectedItem);
702
703
 
704
  }
705
706
	/**
707
	 * Initializes the plugin.
708
 
709
	 * @param gui: A reference to the GUI object.
710
	 */
711
	public void init(GuiInterface gui) {
813 swalkenh 712
	    this.gui = gui;
746 swalkenh 713
 	}
714
715
 
716
	 * Starts the plugin.
717
	 *
718
	 * @param node: The node that the has been chosen.
719
	 * @param environment: The current document.
813 swalkenh 720
	 * @param elementPath: The <code>TreePath</code> of the selected
746 swalkenh 721
	 * node in the evironment.
722
	 *
723
 
724
	 */
725
	public void start(Node node, Document environment, TreePath elementPath)
726
	{
727
        this.environment = environment;
728
    	oldNode = node;
729
 
730
    	gui.getStatusInterface().setIcon(StatusInterface.ICON_NONE);
731
    	gui.getStatusInterface().setMessage(null);
732
 
733
734
    	if (node == null)
735
 
736
    	else
737
    	  imageName = node.getAttributes().getNamedItem("image").getNodeValue();
738
739
 
740
        findImage();
741
742
 
743
        initRegions(node);
744
745
	    gui.setPluginPanel(this);
746
   		setVisible(true);
521 swalkenh 747
	}
748
746 swalkenh 749
    /**
750
     * Finds image URL and loads it.
521 swalkenh 751
 
746 swalkenh 752
    private void findImage()
753
    {
754
		imageUrl = findUrlForImageName(
755
		  gui.getDocumentManagerInterface().getPluginManagerInterface(),
756
		  imageName, environment.getDocumentElement());
757
758
        if (imageUrl==null) {
759
        	gui.getLogInterface().log(LogInterface.TYPE_ERROR,
760
        	  "Picture " + "\"" + imageName + "\"" + " not found in document.");
761
        }
813 swalkenh 762
763
    	loadImage(imageUrl);
764
    }
746 swalkenh 765
813 swalkenh 766
	/**
746 swalkenh 767
	 * Tries to find image URL for label of the image in given node.
768
	 *
769
	 * @param manager: The plugin manager.
770
 
813 swalkenh 771
	 * @param node: The node.
772
	 * @return The URL or null if it can not be found
773
	 */
746 swalkenh 774
    private String findUrlForImageName(PluginManagerInterface manager,
775
 
776
    {
813 swalkenh 777
        // check elements only
746 swalkenh 778
 
813 swalkenh 779
746 swalkenh 780
  	    String associatedPlugin = manager.getAssociatedPlugin(node.getNodeName());
781
 
782
  	    // if this node corresponds to the image viewer - check image name
783
  	    if(associatedPlugin != null && associatedPlugin.equals("ImageViewer")) {
521 swalkenh 784
  	      Node transformedNode = manager.transformsNode(associatedPlugin, node);
785
 
813 swalkenh 786
  	        NamedNodeMap nodeAttr = transformedNode.getAttributes();
787
		    String name = nodeAttr.getNamedItem("name").getNodeValue();
788
  		    String url = nodeAttr.getNamedItem("url").getNodeValue();
789
790
  		    // if the name matchs the image name we are looking for and
791
  		    // the image has an URL - return the URL
792
  		    if(name != null && name.equals(imageName) && url != null) return url;
793
  		  }
521 swalkenh 794
 
813 swalkenh 795
796
  	    // if nothing found - try the children
797
        NodeList list = node.getChildNodes();
798
        for(int i = 0; i < list.getLength(); i++) {
746 swalkenh 799
 
813 swalkenh 800
801
          // if url found - return it immediately
802
 
803
        }
804
746 swalkenh 805
        // nothing found in children
813 swalkenh 806
        return null;
807
	}
808
809
	/**
521 swalkenh 810
	 * Reads the existent regions from document.
813 swalkenh 811
	 *
812
	 * @param node: The node that the has been chosen.
813
	 */
814
    private void initRegions(Node node)
815
    {
521 swalkenh 816
 
813 swalkenh 817
818
 
819
      for(int i = 0; i < children.getLength(); i++) {
820
        Node rectNode = children.item(i);
821
822
        if(rectNode.getNodeName().equals("RECTANGLE")) {
823
          NodeList rectChildren = rectNode.getChildNodes();
824
          int x = 0;
825
          int y = 0;
826
 
827
          int h = 1;
828
          String name = null;
829
          String savedNameOfNode = null;
830
831
          for(int j = 0; j < rectChildren.getLength(); j++) {
832
 
833
834
            // Get coordinates.
835
            if(subnode.getNodeName().equals("COORDS")) {
836
              NamedNodeMap attrs = subnode.getAttributes();
837
 
838
              savedNameOfNode
839
                = attrs.getNamedItem("XMLEditorSavedNameOfNode").getNodeValue();
840
841
 
842
                x = Integer.parseInt(attrs.getNamedItem("x").getNodeValue());
843
                y = Integer.parseInt(attrs.getNamedItem("y").getNodeValue());
521 swalkenh 844
                w = Integer.parseInt(attrs.getNamedItem("w").getNodeValue());
845
 
813 swalkenh 846
              }
847
              catch(NumberFormatException ex) {
848
                // Ignore any errors in coordinates.
849
              }
850
            }
746 swalkenh 851
            else if(subnode.getNodeName().equals("#text")) {
852
              String value = subnode.getNodeValue().trim();
853
521 swalkenh 854
 
746 swalkenh 855
            }
856
          }
857
858
 
859
          region.setSavedNameOfNode(savedNameOfNode);
860
          regions.add(region);
861
        }
862
      }
863
    }
864
865
// debug only !!! delete it in the release
813 swalkenh 866
private void printTree(Node node, int indent)
746 swalkenh 867
 
868
  if(indent == 0)
869
    System.out.println("=================================================");
870
 
813 swalkenh 871
  String name = node.getNodeName();
746 swalkenh 872
  NamedNodeMap attrs = node.getAttributes();
873
  NodeList list = node.getChildNodes();
874
 
813 swalkenh 875
  // indent
876
  for(int i = 0; i < indent*2; i++) System.out.print(" ");
877
 
746 swalkenh 878
  // name
879
  System.out.print(name + ":");
880
881
  // attributes
882
  if(attrs != null) {
883
    for(int i = 0; i < attrs.getLength(); i++)
884
      System.out.print(" " + attrs.item(i).getNodeName() + "=\""
813 swalkenh 885
        + attrs.item(i).getNodeValue() + "\"");
746 swalkenh 886
  }
887
888
  // value
889
  if(node.getNodeValue() != null)
890
 
891
  System.out.println();
892
893
  // children
894
 
813 swalkenh 895
    printTree(list.item(i), indent+1);
896
897
  if(indent == 0)
746 swalkenh 898
    System.out.println("=================================================");
899
}
900
901
 
813 swalkenh 902
	/**
746 swalkenh 903
	 * Stops the plugin by setting it to invisible and resetting the display of the
904
	 * status panel.
905
	 *
906
	 * @see src.plugins.PluginInterface#stop
907
 
908
	public void stop() {
909
	    setVisible(false);
910
    	gui.getStatusInterface().setIcon(StatusInterface.ICON_NONE);
911
 
912
    	gui.getStatusInterface().setPoint(null);
913
  	}
914
 
915
	/* (non-Javadoc)
916
	 * @see src.gui.PluginInterface#setOurEventListener(src.control.OurEventListener)
917
 
918
	public void setOurEventListener(OurEventListener newListener) {
919
		ourEventListener = newListener;
920
	}
921
922
	/**
923
	 * Forces the plugin to report its status.
924
 
925
	public void forceStatusReport() {
926
		changedNode = oldNode.cloneNode(false);
927
		Document tempDoc = oldNode.getOwnerDocument();
928
		changedNode.getAttributes().getNamedItem("image").setNodeValue(imageName);
929
 
930
printTree(oldNode, 0);
931
		Iterator i = regions.iterator();
932
		while(i.hasNext()) {
933
 
934
			Text name = tempDoc.createTextNode(region.getName());
935
			org.w3c.dom.Element geom = tempDoc.createElement("RECTANGLE");
936
			org.w3c.dom.Element coords = tempDoc.createElement("COORDS");
937
 
938
 
939
			/* attribute "XMLEditorSavedNameOfNode" should only appear if the original
940
			 * node was not a "COORDS", cause during transformation this attribute is
941
			 * simply copied if it doesn't contains a proper name */
942
			if ((region.getSavedNameOfNode() != null) && (region.getSavedNameOfNode() != "")) {
943
				coords.setAttribute("XMLEditorSavedNameOfNode", region.getSavedNameOfNode());
521 swalkenh 944
			}
945
			
746 swalkenh 946
			coords.setAttribute("x", Integer.toString(region.getRect().x));
947
			coords.setAttribute("y", Integer.toString(region.getRect().y));
948
			coords.setAttribute("w", Integer.toString(region.getRect().width));
949
			coords.setAttribute("h", Integer.toString(region.getRect().height));
950
			geom.appendChild(name);
521 swalkenh 951
 
952
			changedNode.appendChild((Node)geom);
953
		}
954
printTree(changedNode, 0);
955
956
		firePluginChangedElement(oldNode, changedNode);
957
	}
958
 
813 swalkenh 959
	/**
960
	 * ...
961
	 *
962
	 * @param oldNode: ...
963
	 * @param changedNode: ..
964
	 */
965
	private void firePluginChangedElement(Node oldNode, Node changedNode) {
521 swalkenh 966
 
813 swalkenh 967
		ourEventListener.firedOurEvent(e);
968
	}
969
970
  /**
971
   *  Loads image.
972
   *
973
   *  @param fileName:   The file name that must be shown:
746 swalkenh 974
 
813 swalkenh 975
  private void loadImage(String fileName)
976
  {
977
    //  File is absent.
978
    currentFile = null;
979
980
    // File name is absent: status panel - "No image".
981
    if(fileName == null) {
982
 
983
      gui.getStatusInterface().setIcon(StatusInterface.ICON_WARNING);
984
      gui.getStatusInterface().setMessage("No image");
985
    }
986
    // Gets the current file from the directory where the doc is.
987
    else {
988
      try {
989
        File doc = gui.getCurrentFile();
990
        if(fileName.startsWith(doc.getParentFile().toString())) {
991
          fileName = fileName.replaceFirst(doc.getParentFile().toString() + "/", "");
746 swalkenh 992
 
813 swalkenh 993
994
        if(fileName.charAt(0) == '/')
746 swalkenh 995
 
813 swalkenh 996
        else {
997
          currentFile = new File(doc.getParentFile(), fileName);
998
        }
999
1000
        image = javax.imageio.ImageIO.read(currentFile);
1001
        gui.getStatusInterface().setIcon(StatusInterface.ICON_INFORMATION);
1002
        gui.getStatusInterface().setMessage("Show image from " + fileName);
1003
      }
1004
      catch(IOException ex) {
1005
        gui.getLogInterface().log(
1006
 
746 swalkenh 1007
        gui.getStatusInterface().setIcon(StatusInterface.ICON_ERROR);
1008
        gui.getStatusInterface().setMessage("Cannot open file " + fileName);
1009
      }
813 swalkenh 1010
    }
746 swalkenh 1011
1012
    imagePanel.setImage(image);
1013
  }
1014
1015
  /**
1016
 
1017
   *
1018
   *  @param e:  Some event.
1019
   */
1020
  public void actionPerformed(ActionEvent e)
1021
  {
1022
    if(e.getSource() == confirmButton) {
1023
      imageName = imageNameField.getText();
1024
      forceStatusReport();
1025
      findImage();
1026
    }
1027
1028
    if(e.getSource() == regionConfirmButton) {
1029
      if(selectedRegion != null) {
1030
 
1031
        forceStatusReport();
1032
      }
1033
    }
1034
1035
    if(e.getSource() == deleteSelectedItem) {   // delete the selected region
1036
 
1037
      forceStatusReport();
1038
    }
1039
  }
1040
1041
1042
  /**
1043
   * Invoked when a mouse is pressed on a component.
1044
   *
1045
   * @param e:   Mouse event.
1046
   */
1047
  public void mouseDragged(MouseEvent e)
1048
 
1049
    if(e.getSource() == imagePanel && image != null) {
1050
      showMouse(e.getX(), e.getY());
1051
 
1052
      if(inMove && selectedRegion != null) {  // Move selected region.
1053
        Rectangle rect = selectedRegion.getRect();
1054
        double x = (e.getX() - imagePanel.getDx()) * imagePanel.getCoef();
813 swalkenh 1055
        double y = (e.getY() - imagePanel.getDy()) * imagePanel.getCoef();
746 swalkenh 1056
1057
        if(x < 0) x = 0;
1058
        if(y < 0) y = 0;
1059
1060
        if(x + (int)rect.getWidth() >= image.getWidth(null))
1061
          x = image.getWidth(null) - (int)rect.getWidth() - 1;
813 swalkenh 1062
        if(y + (int)rect.getHeight() >= image.getHeight(null))
746 swalkenh 1063
          y = image.getHeight(null) - (int)rect.getHeight() - 1;
1064
 
1065
        rect.setLocation((int)x, (int)y);
1066
        repaint();
1067
      }
813 swalkenh 1068
      else if(inResize && selectedRegion != null) {  // Resize selected region.
746 swalkenh 1069
        Rectangle rect = selectedRegion.getRect();
1070
        double x = (e.getX() - imagePanel.getDx()) * imagePanel.getCoef();
1071
 
1072
		double w = x - rect.getX();
1073
		double h = y - rect.getY();
813 swalkenh 1074
746 swalkenh 1075
        if(w < 1) w = 1;
1076
        if(h < 1) h = 1;
1077
 
1078
 
1079
          w = image.getWidth(null) - rect.getX();
813 swalkenh 1080
        if(y >= image.getHeight(null))
746 swalkenh 1081
          h = image.getHeight(null) - rect.getY();
813 swalkenh 1082
746 swalkenh 1083
        rect.setSize((int)w, (int)h);
1084
        repaint();
1085
      }
1086
      else {   // Creates a new region.
1087
		double x = (e.getX() - imagePanel.getDx()) * imagePanel.getCoef();
1088
 
1089
1090
        if(x >= 0 && y >= 0 && x < image.getWidth(null) && y < image.getHeight(null)) {
1091
          inResize = true;
1092
          Region region = new Region(null, new Rectangle(
1093
 
1094
            (int)((e.getY() - imagePanel.getDy()) * imagePanel.getCoef()), 1, 1));
1095
          region.setSavedNameOfNode("COORDS");
1096
 
1097
          addRegion(selectedRegion);
1098
        }
1099
      }
1100
    }
1101
 
1102
1103
  /**
1104
   * Invoked when the mouse has been moved on a component (with no buttons no down).
1105
   *
1106
   * @param e:   Mouse event.
1107
   */
1108
  public void mouseMoved(MouseEvent e)
1109
  {
1110
    if(e.getSource() == imagePanel && image != null) {
1111
 
1112
1113
      Region region1 = findRegion(e.getX(), e.getY(), true);  // Try move.
1114
 
1115
      if(region1 != null) {    // Found one.
1116
        setCursor(moveCursor);
1117
      }
1118
      else {                 // Not found - try resize.
1119
 
1120
1121
        if(region2 != null) {    // Found one.
1122
          setCursor(resizeCursor);
1123
        }
1124
        else {                 // Nothing found.
1125
          setCursor(normalCursor);
1126
 
1127
      }
1128
    }
813 swalkenh 1129
  }
746 swalkenh 1130
813 swalkenh 1131
  /**
1132
   * Shows the current position of mouse.
1133
   *
746 swalkenh 1134
   * @param mouseX: Position of mouse.
1135
   * @param mouseY: Position of mouse.
1136
   */
1137
  public void showMouse(int mouseX, int mouseY)
1138
  {
1139
 
1140
    int y = mouseY - imagePanel.getDy();
813 swalkenh 1141
746 swalkenh 1142
    if(x < 0 || y < 0 || x > imagePanel.getImageWidth()
813 swalkenh 1143
      || y > imagePanel.getImageHeight())
746 swalkenh 1144
    {
1145
      gui.getStatusInterface().setPoint(null);
1146
    }
1147
    else {
1148
      int xx = (int)(x * imagePanel.getCoef());
1149
 
1150
1151
 
1152
    }
1153
  }
1154
1155
	/**
1156
	 * Invoked when the mouse has been clicked on a component.
1157
 
1158
	 * @param e: A mouse event indicating that a mouse button has been
1159
	 * clicked on a component.
1160
	 */
1161
	public void mouseClicked(MouseEvent e) {
1162
	    if(e.getSource() == imagePanel && image != null) {
1163
    		selectRegion(e.getX(), e.getY());
1164
      		repaint();
1165
    	}
1166
	}
1167
 
1168
  /**
1169
   * Invoked when a mouse has been pressed on a Component.
1170
   *
813 swalkenh 1171
   * @param e:   Mouse event.
1172
   */
746 swalkenh 1173
  public void mousePressed(MouseEvent e)
1174
  {
1175
    if(e.getSource() == imagePanel && image != null) {
1176
      if(e.isPopupTrigger()) {           // Show popup.
1177
        showPopup(e.getX(), e.getY());
1178
 
1179
      else {                             // Test for move/resize.
1180
        Region region1 = findRegion(e.getX(), e.getY(), true);  // Try move.
1181
1182
        if(region1 != null) {    // Found one.
1183
          setCursor(moveCursor);
1184
          setSelectedRegion(region1);
1185
          inMove = true;
1186
        }
1187
 
1188
          Region region2 = findRegion(e.getX(), e.getY(), false);
1189
1190
          if(region2 != null) {    // Found one.
1191
 
521 swalkenh 1192
            setSelectedRegion(region2);
746 swalkenh 1193
            inResize = true;
1194
          }
1195
          else {                 // Nothing found.
1196
            setCursor(normalCursor);
521 swalkenh 1197
          }
746 swalkenh 1198
        }
1199
      }
1200
    }
1201
  }
1202
521 swalkenh 1203
	/**
746 swalkenh 1204
 
1205
	 *
813 swalkenh 1206
	 * @param e: A mouse event indicating that a mouse button has been
746 swalkenh 1207
	 * pressed on a component.
813 swalkenh 1208
	 */
746 swalkenh 1209
	public void mouseReleased(MouseEvent e) {
1210
1211
		/* If the event was fired by the image panel and an image is available ... */
1212
		if(e.getSource() == imagePanel && image != null) {
1213
    		if(e.isPopupTrigger()) {
1214
	      		showPopup(e.getX(), e.getY());
1215
    		}
1216
1217
          // if a region was moved or resized - update the document
1218
 
1219
            forceStatusReport();
1220
1221
	      inMove = false;
1222
    	  inResize = false;
1223
  		}
1224
	}
1225
1226
 
1227
	 * Empty method needed to implement the <code>MouseListener</code> interface.
1228
	 *
1229
	 * @see java.awt.event.MouseListener#mouseEntered
1230
	 */
1231
	public void mouseEntered(MouseEvent e) {
1232
	}
1233
1234
	/**
1235
	 * Invoked when the mouse exits a component. Will reset the point display
1236
	 * int the status panel.
1237
	 *
1238
	 * @param e: A mouse event indicating that the cursor has left a component.
1239
 
1240
	 * @see java.awt.event.MouseListener#mouseExited
813 swalkenh 1241
	 */
746 swalkenh 1242
	public void mouseExited(MouseEvent e) {
1243
	    if(e.getSource() == imagePanel) {
1244
   			gui.getStatusInterface().setPoint(null);
1245
    	}
1246
  	}
1247
 
1248
  /**
1249
   *  Adds new region.
1250
   *
1251
   * @param region:    Add the given region.
1252
   */
1253
 
813 swalkenh 1254
  {
1255
    regions.add(region);
1256
    repaint();
1257
 
1258
1259
  /**
746 swalkenh 1260
   * Delets a region.
521 swalkenh 1261
   *
746 swalkenh 1262
 
1263
   */
1264
  public void deleteRegion(Region region)
1265
  {
1266
    if(selectedRegion == region) setSelectedRegion(null); // If it was the selected one.
1267
    regions.remove(region);
1268
    repaint();
1269
  }
1270
 
1271
  /**
1272
   * Selects a region.
1273
   *
1274
   * @param x:   Point of region that the user will select.
1275
   * @param y:   Point of region that the user will select.
1276
   */
1277
  private void selectRegion(int x, int y)
1278
  {
1279
    int xx = (int)((x - imagePanel.getDx()) * imagePanel.getCoef());
1280
    int yy = (int)((y - imagePanel.getDy()) * imagePanel.getCoef());
1281
1282
    setSelectedRegion(null); // Reset old selection.
1283
1284
 
1285
      Region region = (Region)regions.get(i);
813 swalkenh 1286
746 swalkenh 1287
      if(region.getRect().contains(xx, yy)) { // Found one.
813 swalkenh 1288
        setSelectedRegion(region);
746 swalkenh 1289
        break;
1290
      }
1291
    }
1292
  }
1293
1294
  /**
1295
 
1296
   *
813 swalkenh 1297
   * @param x: Position of mouse.
746 swalkenh 1298
   * @param y: Position of mouse.
813 swalkenh 1299
   * @param nordWest: If true then top left of corner will be serched,
746 swalkenh 1300
   * else bottom right  of corner will be serched.
1301
   *
1302
   * @return currentRegion or null if nothing was found.
1303
   */
1304
  private Region findRegion(int x, int y, boolean nordWest)
1305
  {
1306
    int xx = (int)((x - imagePanel.getDx()) * imagePanel.getCoef());
1307
 
1308
813 swalkenh 1309
    Region currentRegion = null;
746 swalkenh 1310
813 swalkenh 1311
    for(int i = 0; i < regions.size(); i++) {
1312
      Region region = (Region)regions.get(i);
746 swalkenh 1313
      Rectangle rect = region.getRect();
1314
1315
      if(nordWest) {
1316
        if(Math.abs((int)rect.getX() - xx) < 5
1317
          && Math.abs((int)rect.getY() - yy) < 5)
1318
 
1319
          currentRegion = region;
1320
 
1321
        }
1322
      }
1323
 
1324
        if(Math.abs((int)rect.getX() + (int)rect.getWidth() - xx) < 5
1325
          && Math.abs((int)rect.getY() + (int)rect.getHeight() - yy) < 5)
1326
        {                                                    // Found one.
1327
          currentRegion = region;
1328
          break;
1329
        }
1330
 
1331
    }
813 swalkenh 1332
746 swalkenh 1333
    return currentRegion;
813 swalkenh 1334
  }
1335
1336
  /**
1337
   * Shows popup menu.
746 swalkenh 1338
   *
813 swalkenh 1339
   * @param x: Position of menu.
746 swalkenh 1340
   * @param y: Position of menu.
1341
   */
1342
  private void showPopup(int x, int y)
1343
  {
1344
    selectRegion(x, y);
1345
 
1346
1347
 
1348
    deleteSelectedItem.setEnabled(selectedRegion != null);
1349
    popup.show(this, x, y);
1350
  }
1351
 
1352
	/**
1353
	 * Sets the currently selected region in the image panel.
1354
	 *
1355
	 * @param region:     The region selected.
1356
	 */
1357
	private void setSelectedRegion(Region region) {
1358
		selectedRegion = region;
1359
		imagePanel.setSelectedRegion(region);
1360
1361
		if(selectedRegion == null)
1362
		  regionNameField.setText("");
1363
		else
1364
		  regionNameField.setText(selectedRegion.getName());
1365
	}
1366
}
1367
PK
1368
rŽù.ÉkØX$A$A>src/plugins/regionEditorPlugin/RegionEditorPluginTransform.xsl<!-- to-direction for RegionEditor
1369
 
1370
     updated to given schema from 15/07/2003 
1371
     Last Revision: 25/07/2003 by Sascha Walkenhorst -->
1372
 
1373
<xsl:output method="xml" indent="yes" />
813 swalkenh 1374
746 swalkenh 1375
813 swalkenh 1376
<xsl:template match="node()">
1377
	<xsl:if test="not(name() = ('REGIONS'))">
746 swalkenh 1378
	<xsl:if test="not(name() = ('REGIONSET'))">
1379
	<xsl:if test="not(name() = ('PHOTO'))">
1380
	<xsl:if test="not(name() = ('IMAGE'))">
1381
		<xsl:element name="{name()}">
1382
			<xsl:for-each select="attribute::*">
1383
 
1384
					<xsl:value-of select="." />
1385
				</xsl:attribute>
1386
			</xsl:for-each>
1387
1388
 
1389
			<xsl:for-each select="namespace::*">
1390
				<xsl:attribute name="{name()}">
1391
					<xsl:value-of select="." />
813 swalkenh 1392
				</xsl:attribute>
746 swalkenh 1393
			</xsl:for-each>
1394
-->
1395
1396
			<xsl:for-each select="node()">
1397
 
1398
			</xsl:for-each>
1399
		</xsl:element>
1400
	</xsl:if></xsl:if></xsl:if></xsl:if>
1401
</xsl:template>
1402
1403
<xsl:template match="text()">
1404
	<xsl:variable name="testWhetherEmpty">
813 swalkenh 1405
 
1406
	</xsl:variable>
577 swalkenh 1407
813 swalkenh 1408
	<xsl:if test="normalize-space($testWhetherEmpty) != ''">
545 swalkenh 1409
		<xsl:value-of select="$testWhetherEmpty" />
1410
	</xsl:if>
1411
 
1412
 
813 swalkenh 1413
<xsl:template match="REGIONS"><!-- element-plugin association -->
1414
	<xsl:element name="REGIONSET">
1415
		<!-- set extra attribute saving the original name -->
1416
		<xsl:attribute name="XMLEditorSavedNameOfNode">
1417
			<xsl:value-of select="'REGIONS'" />
1418
		</xsl:attribute>
1419
1420
		<!-- work on attributes -->
1421
		<!-- get information of used image out of attribute 'image' -->
1422
		<xsl:attribute name="image">
1423
			<xsl:value-of select="@image" />
1424
 
1425
		<!-- copy all other attributes -->
1426
		<xsl:for-each select="attribute::*">
1427
			<xsl:if test="not(name(.) = 'image')">
1428
				<xsl:attribute name="{name(.)}">
1429
					<xsl:value-of select="self::node()" />
1430
				</xsl:attribute>
1431
			</xsl:if>
1432
 
1433
1434
		<!-- work on childs -->
1435
		<!-- get information of used rectangle out of child 'RECTANGLE' -->
1436
		<xsl:for-each select="RECTANGLE">
1437
			<xsl:element name="RECTANGLE">
545 swalkenh 1438
				<!-- copy all attributes -->
1439
 
813 swalkenh 1440
					<xsl:attribute name="{name(.)}">
1441
						<xsl:value-of select="self::node()" />
1442
					</xsl:attribute>
1443
				</xsl:for-each>
545 swalkenh 1444
 
813 swalkenh 1445
				<!-- get coordinates -->
1446
				<xsl:for-each select="COORDS">
1447
					<xsl:element name="COORDS">
1448
						<xsl:attribute name="x">
1449
 
577 swalkenh 1450
						</xsl:attribute>
813 swalkenh 1451
						<xsl:attribute name="y">
1452
							<xsl:value-of select="@y" />
1453
						</xsl:attribute>
1454
						<xsl:attribute name="w">
1455
							<xsl:value-of select="@w" />
545 swalkenh 1456
 
1457
						<xsl:attribute name="h">
577 swalkenh 1458
							<xsl:value-of select="@h" />
545 swalkenh 1459
						</xsl:attribute>
577 swalkenh 1460
						<xsl:for-each select="attribute::*">
545 swalkenh 1461
							<xsl:if test="not(name(.) = 'x')">
577 swalkenh 1462
							<xsl:if test="not(name(.) = 'y')">
545 swalkenh 1463
							<xsl:if test="not(name(.) = 'w')">
813 swalkenh 1464
							<xsl:if test="not(name(.) = 'h')">
545 swalkenh 1465
								<xsl:attribute name="{name(.)}">
1466
									<xsl:value-of select="self::node()" />
1467
								</xsl:attribute>
1468
							</xsl:if></xsl:if></xsl:if></xsl:if>
1469
						</xsl:for-each>
1470
 
1471
							<xsl:apply-templates select="." />
577 swalkenh 1472
						</xsl:for-each>
1473
					</xsl:element>
1474
				</xsl:for-each>
813 swalkenh 1475
				<xsl:for-each select="COORD_DATA">
1476
					<xsl:element name="COORDS">
1477
						<!-- Insert an attribute which saves the original name of node,
1478
						     cause all nodes which contain data are transformed to a
1479
						     "COORDS" node. This extra information is used in back-
1480
						     transformation to restore the original name. -->
1481
 
577 swalkenh 1482
							<xsl:value-of select="name(.)" />
1483
						</xsl:attribute>
1484
1485
						<xsl:attribute name="x">
1486
							<xsl:value-of select="@x_pos" />
545 swalkenh 1487
						</xsl:attribute>
577 swalkenh 1488
						<xsl:attribute name="y">
1489
							<xsl:value-of select="@y_pos" />
1490
						</xsl:attribute>
1491
						<xsl:attribute name="w">
1492
							<xsl:value-of select="@width" />
1493
						</xsl:attribute>
1494
						<xsl:attribute name="h">
1495
							<xsl:value-of select="@height" />
1496
						</xsl:attribute>
1497
						<xsl:for-each select="attribute::*">
813 swalkenh 1498
							<xsl:if test="not(name(.) = 'x_pos')">
1499
							<xsl:if test="not(name(.) = 'y_pos')">
1500
							<xsl:if test="not(name(.) = 'width')">
1501
							<xsl:if test="not(name(.) = 'height')">
577 swalkenh 1502
								<xsl:attribute name="{name(.)}">
1503
									<xsl:value-of select="self::node()" />
1504
								</xsl:attribute>
1505
							</xsl:if></xsl:if></xsl:if></xsl:if>
1506
						</xsl:for-each>
1507
						<xsl:for-each select="node()">
813 swalkenh 1508
							<xsl:apply-templates select="." />
577 swalkenh 1509
						</xsl:for-each>
813 swalkenh 1510
					</xsl:element>
1511
				</xsl:for-each>
1512
				
1513
				<!-- copy all other childs -->
746 swalkenh 1514
				<xsl:for-each select="node()">
577 swalkenh 1515
					<xsl:if test="not(name(.) = 'COORDS')">
1516
					<xsl:if test="not(name(.) = 'COORD_DATA')">
1517
						<xsl:apply-templates select="." />
1518
					</xsl:if></xsl:if>
1519
				</xsl:for-each>
1520
			</xsl:element>
813 swalkenh 1521
 
577 swalkenh 1522
1523
		<!-- get information of used ellipse out of child 'ELLIPSE' -->
1524
		<xsl:for-each select="ELLIPSE">
1525
			<xsl:element name="ELLIPSE">
1526
				<!-- copy all attributes -->
1527
				<xsl:for-each select="attribute::*">
1528
					<xsl:attribute name="{name(.)}">
1529
						<xsl:value-of select="self::node()" />
1530
					</xsl:attribute>
1531
				</xsl:for-each>
1532
			
1533
				<!-- get coordinates -->
1534
				<xsl:for-each select="COORDS">
813 swalkenh 1535
					<xsl:element name="COORDS">
1536
						<xsl:attribute name="x">
1537
							<xsl:value-of select="@x" />
1538
						</xsl:attribute>
577 swalkenh 1539
						<xsl:attribute name="y">
1540
							<xsl:value-of select="@y" />
1541
						</xsl:attribute>
1542
						<xsl:attribute name="w">
1543
							<xsl:value-of select="@w" />
1544
						</xsl:attribute>
813 swalkenh 1545
						<xsl:attribute name="h">
577 swalkenh 1546
							<xsl:value-of select="@h" />
1547
						</xsl:attribute>
1548
						<xsl:attribute name="angle">
813 swalkenh 1549
 
577 swalkenh 1550
						</xsl:attribute>
545 swalkenh 1551
						<xsl:for-each select="attribute::*">
813 swalkenh 1552
							<xsl:if test="not(name(.) = 'x')">
1553
							<xsl:if test="not(name(.) = 'y')">
1554
							<xsl:if test="not(name(.) = 'w')">
577 swalkenh 1555
							<xsl:if test="not(name(.) = 'h')">
545 swalkenh 1556
							<xsl:if test="not(name(.) = 'angle')">
1557
								<xsl:attribute name="{name(.)}">
1558
									<xsl:value-of select="self::node()" />
577 swalkenh 1559
 
1560
							</xsl:if></xsl:if></xsl:if></xsl:if></xsl:if>
1561
						</xsl:for-each>
1562
						<xsl:for-each select="node()">
813 swalkenh 1563
							<xsl:apply-templates select="." />
1564
						</xsl:for-each>
1565
					</xsl:element>
1566
				</xsl:for-each>
1567
				
1568
				<!-- copy all other childs -->
1569
 
577 swalkenh 1570
					<xsl:if test="not(name(.) = 'COORDS')">
1571
						<xsl:apply-templates select="." />
1572
					</xsl:if>
1573
				</xsl:for-each>
1574
			</xsl:element>
1575
		</xsl:for-each>
1576
1577
		<!-- get information of used polyline out of child 'POLYLINE' -->
1578
		<xsl:for-each select="POLYLINE">
1579
			<xsl:element name="POLYLINE">
1580
				<!-- copy all attributes -->
1581
				<xsl:for-each select="attribute::*">
1582
					<xsl:attribute name="{name(.)}">
1583
						<xsl:value-of select="self::node()" />
1584
					</xsl:attribute>
1585
				</xsl:for-each>
1586
			
1587
				<!-- get coordinates -->
1588
				<xsl:for-each select="COORDS">
813 swalkenh 1589
					<xsl:element name="COORDS">
1590
						<xsl:attribute name="x">
1591
							<xsl:value-of select="@x" />
1592
						</xsl:attribute>
1593
						<xsl:attribute name="y">
577 swalkenh 1594
							<xsl:value-of select="@y" />
1595
						</xsl:attribute>
1596
						<xsl:for-each select="attribute::*">
1597
							<xsl:if test="not(name(.) = 'x')">
1598
							<xsl:if test="not(name(.) = 'y')">
1599
								<xsl:attribute name="{name(.)}">
813 swalkenh 1600
									<xsl:value-of select="self::node()" />
577 swalkenh 1601
								</xsl:attribute>
1602
							</xsl:if></xsl:if>
1603
						</xsl:for-each>
813 swalkenh 1604
 
577 swalkenh 1605
							<xsl:apply-templates select="." />
1606
						</xsl:for-each>
813 swalkenh 1607
					</xsl:element>
1608
				</xsl:for-each>
577 swalkenh 1609
				
1610
				<!-- copy all other childs -->
1611
				<xsl:for-each select="node()">
1612
					<xsl:if test="not(name(.) = 'COORDS')">
1613
 
1614
					</xsl:if>
1615
				</xsl:for-each>
1616
			</xsl:element>
813 swalkenh 1617
		</xsl:for-each>
1618
1619
		<!-- copy all other childs -->
1620
		<xsl:for-each select="node()">
1621
			<xsl:if test="not(name(.) = 'RECTANGLE')">
1622
			<xsl:if test="not(name(.) = 'ELLIPSE')">
1623
 
577 swalkenh 1624
				<xsl:apply-templates select="." />
1625
			</xsl:if></xsl:if></xsl:if>
1626
		</xsl:for-each>
1627
1628
	</xsl:element>
1629
</xsl:template>
1630
1631
<xsl:template match="REGIONSET"><!-- element-plugin association -->
1632
	<xsl:element name="REGIONSET">
1633
813 swalkenh 1634
		<!-- work on attributes -->
1635
		<!-- get information of used image out of attribute 'image' -->
577 swalkenh 1636
		<xsl:attribute name="image">
1637
			<xsl:value-of select="@image" />
1638
		</xsl:attribute>
1639
		<!-- copy all other attributes -->
1640
		<xsl:for-each select="attribute::*">
1641
			<xsl:if test="not(name(.) = ('image'))">
813 swalkenh 1642
				<xsl:attribute name="{name(.)}">
577 swalkenh 1643
					<xsl:value-of select="self::node()" />
1644
				</xsl:attribute>
1645
			</xsl:if>
813 swalkenh 1646
 
577 swalkenh 1647
1648
		<!-- work on childs -->
813 swalkenh 1649
		<!-- get information of used rectangle out of child 'RECTANGLE' -->
1650
		<xsl:for-each select="RECTANGLE">
577 swalkenh 1651
			<xsl:element name="RECTANGLE">
1652
				<!-- copy all attributes -->
1653
				<xsl:for-each select="attribute::*">
1654
					<xsl:attribute name="{name(.)}">
1655
 
1656
					</xsl:attribute>
545 swalkenh 1657
				</xsl:for-each>
813 swalkenh 1658
			
1659
				<!-- get coordinates -->
1660
				<xsl:for-each select="COORDS">
1661
					<xsl:element name="COORDS">
577 swalkenh 1662
						<xsl:attribute name="x">
545 swalkenh 1663
							<xsl:value-of select="@x" />
1664
 
1665
						<xsl:attribute name="y">
1666
							<xsl:value-of select="@y" />
1667
 
1668
						<xsl:attribute name="w">
577 swalkenh 1669
							<xsl:value-of select="@w" />
1670
 
1671
						<xsl:attribute name="h">
1672
							<xsl:value-of select="@h" />
1673
						</xsl:attribute>
1674
						<xsl:for-each select="attribute::*">
1675
							<xsl:if test="not(name(.) = 'x')">
1676
							<xsl:if test="not(name(.) = 'y')">
1677
							<xsl:if test="not(name(.) = 'w')">
813 swalkenh 1678
							<xsl:if test="not(name(.) = 'h')">
577 swalkenh 1679
								<xsl:attribute name="{name(.)}">
1680
									<xsl:value-of select="self::node()" />
1681
								</xsl:attribute>
1682
							</xsl:if></xsl:if></xsl:if></xsl:if>
1683
						</xsl:for-each>
1684
 
1685
							<xsl:apply-templates select="." />
1686
						</xsl:for-each>
1687
					</xsl:element>
1688
				</xsl:for-each>
813 swalkenh 1689
				<xsl:for-each select="COORD_DATA">
1690
					<xsl:element name="COORDS">
1691
						<!-- Insert an attribute which saves the original name of node,
1692
						     cause all nodes which contain data are transformed to a
1693
						     "COORDS" node. This extra information is used in back-
1694
						     transformation to restore the original name. -->
1695
 
577 swalkenh 1696
							<xsl:value-of select="name(.)" />
1697
						</xsl:attribute>
1698
1699
						<xsl:attribute name="x">
1700
							<xsl:value-of select="@x_pos" />
1701
						</xsl:attribute>
1702
						<xsl:attribute name="y">
1703
							<xsl:value-of select="@y_pos" />
1704
						</xsl:attribute>
1705
						<xsl:attribute name="w">
1706
							<xsl:value-of select="@width" />
1707
						</xsl:attribute>
1708
						<xsl:attribute name="h">
1709
							<xsl:value-of select="@height" />
1710
						</xsl:attribute>
1711
						<xsl:for-each select="attribute::*">
813 swalkenh 1712
							<xsl:if test="not(name(.) = 'x_pos')">
1713
							<xsl:if test="not(name(.) = 'y_pos')">
1714
							<xsl:if test="not(name(.) = 'width')">
1715
							<xsl:if test="not(name(.) = 'height')">
577 swalkenh 1716
								<xsl:attribute name="{name(.)}">
1717
									<xsl:value-of select="self::node()" />
1718
								</xsl:attribute>
1719
							</xsl:if></xsl:if></xsl:if></xsl:if>
1720
						</xsl:for-each>
1721
						<xsl:for-each select="node()">
813 swalkenh 1722
							<xsl:apply-templates select="." />
577 swalkenh 1723
						</xsl:for-each>
813 swalkenh 1724
					</xsl:element>
1725
				</xsl:for-each>
1726
				
1727
				<!-- copy all other childs -->
746 swalkenh 1728
				<xsl:for-each select="node()">
577 swalkenh 1729
					<xsl:if test="not(name(.) = 'COORDS')">
1730
					<xsl:if test="not(name(.) = 'COORD_DATA')">
1731
						<xsl:apply-templates select="." />
1732
					</xsl:if></xsl:if>
1733
				</xsl:for-each>
1734
			</xsl:element>
813 swalkenh 1735
 
577 swalkenh 1736
1737
		<!-- get information of used ellipse out of child 'ELLIPSE' -->
1738
		<xsl:for-each select="ELLIPSE">
1739
			<xsl:element name="ELLIPSE">
1740
				<!-- copy all attributes -->
1741
				<xsl:for-each select="attribute::*">
1742
					<xsl:attribute name="{name(.)}">
1743
						<xsl:value-of select="self::node()" />
1744
					</xsl:attribute>
1745
				</xsl:for-each>
1746
			
1747
				<!-- get coordinates -->
1748
				<xsl:for-each select="COORDS">
813 swalkenh 1749
					<xsl:element name="COORDS">
1750
						<xsl:attribute name="x">
1751
							<xsl:value-of select="@x" />
1752
						</xsl:attribute>
577 swalkenh 1753
						<xsl:attribute name="y">
1754
							<xsl:value-of select="@y" />
1755
						</xsl:attribute>
1756
						<xsl:attribute name="w">
1757
							<xsl:value-of select="@w" />
1758
						</xsl:attribute>
813 swalkenh 1759
						<xsl:attribute name="h">
577 swalkenh 1760
							<xsl:value-of select="@h" />
1761
						</xsl:attribute>
1762
						<xsl:attribute name="angle">
813 swalkenh 1763
 
577 swalkenh 1764
						</xsl:attribute>
1765
						<xsl:for-each select="attribute::*">
813 swalkenh 1766
							<xsl:if test="not(name(.) = 'x')">
1767
							<xsl:if test="not(name(.) = 'y')">
1768
							<xsl:if test="not(name(.) = 'w')">
577 swalkenh 1769
							<xsl:if test="not(name(.) = 'h')">
1770
							<xsl:if test="not(name(.) = 'angle')">
1771
								<xsl:attribute name="{name(.)}">
1772
									<xsl:value-of select="self::node()" />
1773
 
1774
							</xsl:if></xsl:if></xsl:if></xsl:if></xsl:if>
1775
						</xsl:for-each>
1776
						<xsl:for-each select="node()">
813 swalkenh 1777
							<xsl:apply-templates select="." />
1778
						</xsl:for-each>
1779
					</xsl:element>
1780
				</xsl:for-each>
1781
				
1782
				<!-- copy all other childs -->
1783
 
577 swalkenh 1784
					<xsl:if test="not(name(.) = 'COORDS')">
1785
						<xsl:apply-templates select="." />
1786
					</xsl:if>
1787
				</xsl:for-each>
1788
			</xsl:element>
1789
		</xsl:for-each>
1790
1791
		<!-- get information of used polyline out of child 'POLYLINE' -->
1792
		<xsl:for-each select="POLYLINE">
1793
			<xsl:element name="POLYLINE">
1794
				<!-- copy all attributes -->
1795
				<xsl:for-each select="attribute::*">
1796
					<xsl:attribute name="{name(.)}">
1797
						<xsl:value-of select="self::node()" />
1798
					</xsl:attribute>
1799
				</xsl:for-each>
1800
			
1801
				<!-- get coordinates -->
1802
				<xsl:for-each select="COORDS">
813 swalkenh 1803
					<xsl:element name="COORDS">
1804
						<xsl:attribute name="x">
1805
							<xsl:value-of select="@x" />
1806
						</xsl:attribute>
1807
						<xsl:attribute name="y">
577 swalkenh 1808
							<xsl:value-of select="@y" />
1809
						</xsl:attribute>
1810
						<xsl:for-each select="attribute::*">
1811
							<xsl:if test="not(name(.) = 'x')">
1812
							<xsl:if test="not(name(.) = 'y')">
1813
								<xsl:attribute name="{name(.)}">
813 swalkenh 1814
									<xsl:value-of select="self::node()" />
577 swalkenh 1815
								</xsl:attribute>
1816
							</xsl:if></xsl:if>
1817
						</xsl:for-each>
813 swalkenh 1818
 
577 swalkenh 1819
							<xsl:apply-templates select="." />
1820
						</xsl:for-each>
813 swalkenh 1821
					</xsl:element>
1822
				</xsl:for-each>
577 swalkenh 1823
				
1824
				<!-- copy all other childs -->
1825
				<xsl:for-each select="node()">
1826
					<xsl:if test="not(name(.) = 'COORDS')">
1827
 
1828
					</xsl:if>
1829
				</xsl:for-each>
1830
			</xsl:element>
813 swalkenh 1831
		</xsl:for-each>
1832
1833
		<!-- copy all other childs -->
1834
		<xsl:for-each select="node()">
1835
			<xsl:if test="not(name(.) = 'RECTANGLE')">
1836
			<xsl:if test="not(name(.) = 'ELLIPSE')">
1837
 
577 swalkenh 1838
				<xsl:apply-templates select="." />
1839
			</xsl:if></xsl:if></xsl:if>
1840
		</xsl:for-each>
1841
1842
	</xsl:element>
1843
</xsl:template>
1844
1845
<xsl:template match="PHOTO">
1846
	<xsl:element name="IMAGE">
1847
		<!-- set extra attribute saving the original name -->
813 swalkenh 1848
		<xsl:attribute name="XMLEditorSavedNameOfNode">
1849
			<xsl:value-of select="'PHOTO'" />
577 swalkenh 1850
		</xsl:attribute>
1851
		
1852
		<!-- work on attributes and childs -->
1853
		<xsl:attribute name="name">
1854
			<xsl:value-of select="@label" />
1855
		</xsl:attribute>
813 swalkenh 1856
		<xsl:attribute name="url">
577 swalkenh 1857
			<xsl:value-of select="@uri" />
1858
		</xsl:attribute>
1859
		<xsl:for-each select="attribute::*">
813 swalkenh 1860
 
577 swalkenh 1861
			<xsl:if test="not(name(.) = ('uri'))">
1862
				<xsl:attribute name="{name(.)}">
813 swalkenh 1863
					<xsl:value-of select="self::node()" />
1864
				</xsl:attribute>
577 swalkenh 1865
			</xsl:if></xsl:if>
1866
		</xsl:for-each>
1867
		<xsl:for-each select="node()">
1868
			<xsl:apply-templates select="." />
1869
 
1870
	</xsl:element>
1871
</xsl:template>
813 swalkenh 1872
1873
<xsl:template match="IMAGE">
1874
	<xsl:element name="IMAGE">
1875
		<!-- work on attributes and childs -->
577 swalkenh 1876
		<xsl:attribute name="name">
1877
			<xsl:value-of select="@label" />
1878
 
1879
		<xsl:attribute name="url">
545 swalkenh 1880
			<xsl:value-of select="@uri" />
1881
 
813 swalkenh 1882
		<xsl:for-each select="attribute::*">
1883
			<xsl:if test="not(name(.) = ('label'))">
1884
			<xsl:if test="not(name(.) = ('uri'))">
1885
				<xsl:attribute name="{name(.)}">
1886
					<xsl:value-of select="self::node()" />
1887
				</xsl:attribute>
1888
 
1889
		</xsl:for-each>
1890
		<xsl:for-each select="node()">
1891
			<xsl:apply-templates select="." />
1892
		</xsl:for-each>
1893
	</xsl:element>
1894
</xsl:template>
1895
1896
1897
</xsl:stylesheet>PK
1898
ðhù.î}ñDñDBsrc/plugins/regionEditorPlugin/RegionEditorPluginTransformBack.xsl<!-- back-direction for RegionEditor
1899
     status: problems with namespace and comments
1900
     updated to given schema from 15/07/2003 
1901
     Last Revision: 25/07/2003 by Sascha Walkenhorst -->
1902
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
1903
<xsl:output method="xml" indent="yes" />
1904
1905
1906
<xsl:template match="node()">
1907
	<xsl:if test="not(name() = ('REGIONSET'))">
1908
	<xsl:if test="not(name() = ('IMAGE'))">
545 swalkenh 1909
 
813 swalkenh 1910
			<xsl:for-each select="attribute::*">
1911
				<xsl:attribute name="{name()}">
1912
					<xsl:value-of select="." />
1913
				</xsl:attribute>
1914
			</xsl:for-each>
1915
		
1916
			<xsl:for-each select="node()">
1917
				<xsl:apply-templates select="." />
1918
			</xsl:for-each>
1919
		</xsl:element>
1920
	</xsl:if></xsl:if>
1921
</xsl:template>
1922
1923
<xsl:template match="text()">
1924
	<xsl:variable name="testWhetherEmpty">
1925
		<xsl:value-of select="." />
1926
	</xsl:variable>
1927
1928
	<xsl:if test="normalize-space($testWhetherEmpty) != ''">
1929
		<xsl:value-of select="$testWhetherEmpty" />
1930
	</xsl:if>
1931
</xsl:template>
1932
 
1933
 
240 swalkenh 1934
<xsl:template match="REGIONSET">
813 swalkenh 1935
 
1936
		<xsl:when test="@XMLEditorSavedNameOfNode = 'REGIONS'">
577 swalkenh 1937
			<xsl:element name="REGIONS">
813 swalkenh 1938
		
545 swalkenh 1939
				<!-- work on attributes -->
1940
				<!-- get information of used image out of attribute 'image' -->
1941
 
1942
 
813 swalkenh 1943
				</xsl:attribute>
1944
				<!-- copy all other attributes -->
1945
				<xsl:for-each select="attribute::*">
1946
					<xsl:if test="not(name(.) = 'image')">
1947
					<xsl:if test="not(name(.) = 'XMLEditorSavedNameOfNode')">
1948
						<xsl:attribute name="{name(.)}">
1949
							<xsl:value-of select="self::node()" />
1950
						</xsl:attribute>
1951
					</xsl:if></xsl:if>
1952
 
1953
		
1954
				<!-- work on childs -->
1955
				<!-- get information of used rectangle out of child 'RECTANGLE' -->
1956
				<xsl:for-each select="RECTANGLE">
1957
					<xsl:element name="RECTANGLE">
545 swalkenh 1958
						<!-- copy all attributes -->
1959
 
813 swalkenh 1960
							<xsl:attribute name="{name(.)}">
1961
								<xsl:value-of select="self::node()" />
1962
							</xsl:attribute>
1963
						</xsl:for-each>
545 swalkenh 1964
 
813 swalkenh 1965
						<!-- get coordinates -->
1966
						<!-- during transformation in to-direction an attribute named 
1967
						     "XMLEditorSavedNameOfNode" should have been created which
1968
						     contains the name of the element the original element had
545 swalkenh 1969
 
813 swalkenh 1970
 
1971
						<xsl:for-each select="COORDS">
1972
							<xsl:choose>
1973
								<xsl:when test="@XMLEditorSavedNameOfNode = 'COORD_DATA'">
1974
									<xsl:element name="COORD_DATA">
1975
 
1976
											<xsl:value-of select="@x" />
1977
										</xsl:attribute>
1978
										<xsl:attribute name="y_pos">
1979
											<xsl:value-of select="@y" />
545 swalkenh 1980
										</xsl:attribute>
813 swalkenh 1981
										<xsl:attribute name="width">
1982
											<xsl:value-of select="@w" />
1983
										</xsl:attribute>
1984
										<xsl:attribute name="height">
1985
											<xsl:value-of select="@h" />
1986
										</xsl:attribute>
545 swalkenh 1987
										<xsl:for-each select="attribute::*">
813 swalkenh 1988
											<xsl:if test="not(name(.) = 'x')">
1989
											<xsl:if test="not(name(.) = 'y')">
1990
 
1991
											<xsl:if test="not(name(.) = 'h')">
1992
											<xsl:if test="not(name(.) = 'XMLEditorSavedNameOfNode')">
1993
												<xsl:attribute name="{name(.)}">
1994
													<xsl:value-of select="self::node()" />
1995
												</xsl:attribute>
577 swalkenh 1996
											</xsl:if></xsl:if></xsl:if></xsl:if></xsl:if>
813 swalkenh 1997
										</xsl:for-each>
1998
										<xsl:for-each select="node()">
1999
											<xsl:apply-templates select="." />
577 swalkenh 2000
										</xsl:for-each>
813 swalkenh 2001
 
2002
								</xsl:when>
2003
								<xsl:otherwise>
2004
									<xsl:element name="COORDS">
2005
										<xsl:attribute name="x">
2006
											<xsl:value-of select="@x" />
2007
										</xsl:attribute>
2008
										<xsl:attribute name="y">
2009
											<xsl:value-of select="@y" />
2010
										</xsl:attribute>
2011
										<xsl:attribute name="w">
2012
											<xsl:value-of select="@w" />
2013
										</xsl:attribute>
2014
										<xsl:attribute name="h">
2015
											<xsl:value-of select="@h" />
2016
										</xsl:attribute>
2017
										<xsl:for-each select="attribute::*">
2018
											<xsl:if test="not(name(.) = 'x')">
2019
											<xsl:if test="not(name(.) = 'y')">
2020
											<xsl:if test="not(name(.) = 'w')">
2021
											<xsl:if test="not(name(.) = 'h')">
2022
												<xsl:attribute name="{name(.)}">
2023
													<xsl:value-of select="self::node()" />
2024
												</xsl:attribute>
2025
											</xsl:if></xsl:if></xsl:if></xsl:if>
2026
										</xsl:for-each>
2027
										<xsl:for-each select="node()">
2028
											<xsl:apply-templates select="." />
2029
										</xsl:for-each>
2030
									</xsl:element>
2031
								</xsl:otherwise>
2032
							</xsl:choose>
2033
						</xsl:for-each>
2034
		
2035
						<!-- copy all other childs -->
2036
						<xsl:for-each select="node()">
2037
							<xsl:if test="not(name(.) = 'COORDS')">
2038
								<xsl:apply-templates select="." />
2039
							</xsl:if>
2040
						</xsl:for-each>
2041
					</xsl:element>
2042
				</xsl:for-each>
2043
		
2044
				<!-- get information of used ellipse out of child 'ELLIPSE' -->
2045
				<xsl:for-each select="ELLIPSE">
2046
					<xsl:element name="ELLIPSE">
2047
						<!-- copy all attributes -->
2048
						<xsl:for-each select="attribute::*">
2049
							<xsl:attribute name="{name(.)}">
2050
								<xsl:value-of select="self::node()" />
2051
							</xsl:attribute>
2052
						</xsl:for-each>
2053
			
2054
						<!-- get coordinates -->
2055
						<xsl:for-each select="COORDS">
2056
							<xsl:element name="COORDS">
2057
								<xsl:attribute name="x">
2058
									<xsl:value-of select="@x" />
2059
								</xsl:attribute>
2060
								<xsl:attribute name="y">
2061
									<xsl:value-of select="@y" />
2062
								</xsl:attribute>
2063
								<xsl:attribute name="w">
2064
									<xsl:value-of select="@w" />
2065
								</xsl:attribute>
2066
								<xsl:attribute name="h">
2067
									<xsl:value-of select="@h" />
2068
								</xsl:attribute>
2069
								<xsl:attribute name="angle">
2070
									<xsl:value-of select="@angle" />
2071
 
2072
								<xsl:for-each select="attribute::*">
577 swalkenh 2073
									<xsl:if test="not(name(.) = 'x')">
813 swalkenh 2074
									<xsl:if test="not(name(.) = 'y')">
2075
									<xsl:if test="not(name(.) = 'w')">
2076
									<xsl:if test="not(name(.) = 'h')">
577 swalkenh 2077
									<xsl:if test="not(name(.) = 'angle')">
2078
										<xsl:attribute name="{name(.)}">
545 swalkenh 2079
											<xsl:value-of select="self::node()" />
813 swalkenh 2080
 
2081
									</xsl:if></xsl:if></xsl:if></xsl:if></xsl:if>
2082
								</xsl:for-each>
2083
								<xsl:for-each select="node()">
2084
									<xsl:apply-templates select="." />
577 swalkenh 2085
								</xsl:for-each>
813 swalkenh 2086
							</xsl:element>
2087
						</xsl:for-each>
2088
						<!-- copy all other childs -->
2089
						<xsl:for-each select="node()">
2090
 
2091
								<xsl:apply-templates select="." />
2092
							</xsl:if>
2093
						</xsl:for-each>
2094
					</xsl:element>
2095
				</xsl:for-each>
577 swalkenh 2096
		
813 swalkenh 2097
				<!-- get information of used polyline out of child 'POLYLINE' -->
2098
				<xsl:for-each select="POLYLINE">
2099
					<xsl:element name="POLYLINE">
2100
						<!-- copy all attributes -->
2101
						<xsl:for-each select="attribute::*">
2102
							<xsl:attribute name="{name(.)}">
2103
								<xsl:value-of select="self::node()" />
2104
							</xsl:attribute>
2105
						</xsl:for-each>
2106
			
2107
						<!-- get coordinates -->
2108
						<xsl:for-each select="COORDS">
2109
							<xsl:element name="COORDS">
2110
								<xsl:attribute name="x">
2111
									<xsl:value-of select="@x" />
2112
								</xsl:attribute>
2113
								<xsl:attribute name="y">
2114
									<xsl:value-of select="@y" />
2115
								</xsl:attribute>
2116
								<xsl:for-each select="attribute::*">
2117
									<xsl:if test="not(name(.) = 'x')">
2118
									<xsl:if test="not(name(.) = 'y')">
2119
										<xsl:attribute name="{name(.)}">
2120
											<xsl:value-of select="self::node()" />
2121
										</xsl:attribute>
2122
									</xsl:if></xsl:if>
2123
								</xsl:for-each>
577 swalkenh 2124
								<xsl:for-each select="node()">
813 swalkenh 2125
									<xsl:apply-templates select="." />
577 swalkenh 2126
								</xsl:for-each>
813 swalkenh 2127
							</xsl:element>
2128
						</xsl:for-each>
2129
						<!-- copy all other childs -->
577 swalkenh 2130
						<xsl:for-each select="node()">
2131
							<xsl:if test="not(name(.) = 'COORDS')">
2132
								<xsl:apply-templates select="." />
813 swalkenh 2133
 
2134
						</xsl:for-each>
2135
					</xsl:element>
2136
				</xsl:for-each>
2137
		
577 swalkenh 2138
				<!-- copy all other childs -->
813 swalkenh 2139
				<xsl:for-each select="node()">
2140
					<xsl:if test="not(name(.) = 'RECTANGLE')">
2141
					<xsl:if test="not(name(.) = 'ELLIPSE')">
2142
					<xsl:if test="not(name(.) = 'POLYLINE')">
2143
 
2144
					</xsl:if></xsl:if></xsl:if>
2145
				</xsl:for-each>
2146
		
2147
			</xsl:element>
2148
		</xsl:when>
577 swalkenh 2149
		
813 swalkenh 2150
		<xsl:otherwise>
2151
			<xsl:element name="REGIONSET">
2152
		
2153
				<!-- work on attributes -->
2154
				<!-- get information of used image out of attribute 'image' -->
2155
				<xsl:attribute name="image">
2156
					<xsl:value-of select="@image" />
2157
				</xsl:attribute>
2158
				<!-- copy all other attributes -->
2159
				<xsl:for-each select="attribute::*">
2160
					<xsl:if test="not(name(.) = 'image')">
2161
					<xsl:if test="not(name(.) = 'XMLEditorSavedNameOfNode')">
2162
						<xsl:attribute name="{name(.)}">
2163
							<xsl:value-of select="self::node()" />
2164
						</xsl:attribute>
577 swalkenh 2165
					</xsl:if></xsl:if>
813 swalkenh 2166
				</xsl:for-each>
577 swalkenh 2167
		
813 swalkenh 2168
				<!-- work on childs -->
2169
				<!-- get information of used rectangle out of child 'RECTANGLE' -->
2170
				<xsl:for-each select="RECTANGLE">
577 swalkenh 2171
					<xsl:element name="RECTANGLE">
2172
						<!-- copy all attributes -->
2173
						<xsl:for-each select="attribute::*">
813 swalkenh 2174
 
577 swalkenh 2175
								<xsl:value-of select="self::node()" />
2176
							</xsl:attribute>
813 swalkenh 2177
						</xsl:for-each>
2178
			
2179
						<!-- get coordinates -->
2180
						<!-- during transformation in to-direction an attribute named 
2181
						     "XMLEditorSavedNameOfNode" should have been created which
577 swalkenh 2182
						     contains the name of the element the original element had
813 swalkenh 2183
 
577 swalkenh 2184
						     this information can the original element reconstructed.-->
813 swalkenh 2185
						<xsl:for-each select="COORDS">
2186
 
2187
								<xsl:when test="@XMLEditorSavedNameOfNode = 'COORD_DATA'">
2188
									<xsl:element name="COORD_DATA">
2189
 
2190
											<xsl:value-of select="@x" />
2191
										</xsl:attribute>
2192
										<xsl:attribute name="y_pos">
2193
											<xsl:value-of select="@y" />
577 swalkenh 2194
										</xsl:attribute>
813 swalkenh 2195
										<xsl:attribute name="width">
2196
											<xsl:value-of select="@w" />
2197
										</xsl:attribute>
2198
										<xsl:attribute name="height">
2199
											<xsl:value-of select="@h" />
2200
										</xsl:attribute>
577 swalkenh 2201
										<xsl:for-each select="attribute::*">
813 swalkenh 2202
											<xsl:if test="not(name(.) = 'x')">
2203
											<xsl:if test="not(name(.) = 'y')">
2204
 
2205
											<xsl:if test="not(name(.) = 'h')">
2206
											<xsl:if test="not(name(.) = 'XMLEditorSavedNameOfNode')">
2207
												<xsl:attribute name="{name(.)}">
2208
													<xsl:value-of select="self::node()" />
2209
												</xsl:attribute>
577 swalkenh 2210
											</xsl:if></xsl:if></xsl:if></xsl:if></xsl:if>
813 swalkenh 2211
										</xsl:for-each>
2212
										<xsl:for-each select="node()">
2213
											<xsl:apply-templates select="." />
577 swalkenh 2214
										</xsl:for-each>
813 swalkenh 2215
 
2216
								</xsl:when>
2217
								<xsl:otherwise>
2218
									<xsl:element name="COORDS">
2219
										<xsl:attribute name="x">
2220
											<xsl:value-of select="@x" />
2221
										</xsl:attribute>
2222
										<xsl:attribute name="y">
2223
											<xsl:value-of select="@y" />
2224
										</xsl:attribute>
2225
										<xsl:attribute name="w">
2226
											<xsl:value-of select="@w" />
2227
										</xsl:attribute>
2228
										<xsl:attribute name="h">
2229
											<xsl:value-of select="@h" />
2230
										</xsl:attribute>
2231
										<xsl:for-each select="attribute::*">
2232
											<xsl:if test="not(name(.) = 'x')">
2233
											<xsl:if test="not(name(.) = 'y')">
2234
											<xsl:if test="not(name(.) = 'w')">
2235
											<xsl:if test="not(name(.) = 'h')">
2236
												<xsl:attribute name="{name(.)}">
2237
													<xsl:value-of select="self::node()" />
2238
												</xsl:attribute>
2239
											</xsl:if></xsl:if></xsl:if></xsl:if>
2240
										</xsl:for-each>
2241
										<xsl:for-each select="node()">
2242
											<xsl:apply-templates select="." />
2243
										</xsl:for-each>
2244
									</xsl:element>
2245
								</xsl:otherwise>
2246
							</xsl:choose>
2247
						</xsl:for-each>
2248
		
2249
						<!-- copy all other childs -->
2250
						<xsl:for-each select="node()">
2251
							<xsl:if test="not(name(.) = 'COORDS')">
2252
								<xsl:apply-templates select="." />
2253
							</xsl:if>
2254
						</xsl:for-each>
2255
					</xsl:element>
2256
				</xsl:for-each>
2257
		
2258
				<!-- get information of used ellipse out of child 'ELLIPSE' -->
2259
				<xsl:for-each select="ELLIPSE">
2260
					<xsl:element name="ELLIPSE">
2261
						<!-- copy all attributes -->
2262
						<xsl:for-each select="attribute::*">
2263
							<xsl:attribute name="{name(.)}">
2264
								<xsl:value-of select="self::node()" />
2265
							</xsl:attribute>
2266
						</xsl:for-each>
2267
			
2268
						<!-- get coordinates -->
2269
						<xsl:for-each select="COORDS">
2270
							<xsl:element name="COORDS">
2271
								<xsl:attribute name="x">
2272
									<xsl:value-of select="@x" />
2273
								</xsl:attribute>
2274
								<xsl:attribute name="y">
2275
									<xsl:value-of select="@y" />
2276
								</xsl:attribute>
2277
								<xsl:attribute name="w">
2278
									<xsl:value-of select="@w" />
2279
								</xsl:attribute>
2280
								<xsl:attribute name="h">
2281
									<xsl:value-of select="@h" />
2282
								</xsl:attribute>
2283
								<xsl:attribute name="angle">
2284
									<xsl:value-of select="@angle" />
2285
 
2286
								<xsl:for-each select="attribute::*">
577 swalkenh 2287
									<xsl:if test="not(name(.) = 'x')">
813 swalkenh 2288
									<xsl:if test="not(name(.) = 'y')">
2289
									<xsl:if test="not(name(.) = 'w')">
2290
									<xsl:if test="not(name(.) = 'h')">
577 swalkenh 2291
									<xsl:if test="not(name(.) = 'angle')">
2292
										<xsl:attribute name="{name(.)}">
2293
											<xsl:value-of select="self::node()" />
813 swalkenh 2294
 
2295
									</xsl:if></xsl:if></xsl:if></xsl:if></xsl:if>
2296
								</xsl:for-each>
2297
								<xsl:for-each select="node()">
2298
									<xsl:apply-templates select="." />
577 swalkenh 2299
								</xsl:for-each>
813 swalkenh 2300
							</xsl:element>
2301
						</xsl:for-each>
2302
						<!-- copy all other childs -->
2303
						<xsl:for-each select="node()">
2304
 
2305
								<xsl:apply-templates select="." />
2306
							</xsl:if>
2307
						</xsl:for-each>
2308
					</xsl:element>
2309
				</xsl:for-each>
577 swalkenh 2310
		
813 swalkenh 2311
				<!-- get information of used polyline out of child 'POLYLINE' -->
2312
				<xsl:for-each select="POLYLINE">
2313
					<xsl:element name="POLYLINE">
2314
						<!-- copy all attributes -->
2315
						<xsl:for-each select="attribute::*">
2316
							<xsl:attribute name="{name(.)}">
2317
								<xsl:value-of select="self::node()" />
2318
							</xsl:attribute>
2319
						</xsl:for-each>
2320
			
2321
						<!-- get coordinates -->
2322
						<xsl:for-each select="COORDS">
2323
							<xsl:element name="COORDS">
2324
								<xsl:attribute name="x">
2325
									<xsl:value-of select="@x" />
2326
								</xsl:attribute>
2327
								<xsl:attribute name="y">
2328
									<xsl:value-of select="@y" />
2329
								</xsl:attribute>
2330
								<xsl:for-each select="attribute::*">
2331
									<xsl:if test="not(name(.) = 'x')">
2332
									<xsl:if test="not(name(.) = 'y')">
2333
										<xsl:attribute name="{name(.)}">
2334
											<xsl:value-of select="self::node()" />
2335
										</xsl:attribute>
2336
									</xsl:if></xsl:if>
2337
								</xsl:for-each>
577 swalkenh 2338
								<xsl:for-each select="node()">
813 swalkenh 2339
									<xsl:apply-templates select="." />
577 swalkenh 2340
								</xsl:for-each>
813 swalkenh 2341
							</xsl:element>
2342
						</xsl:for-each>
2343
						<!-- copy all other childs -->
577 swalkenh 2344
						<xsl:for-each select="node()">
2345
							<xsl:if test="not(name(.) = 'COORDS')">
2346
								<xsl:apply-templates select="." />
813 swalkenh 2347
 
2348
						</xsl:for-each>
2349
					</xsl:element>
2350
				</xsl:for-each>
2351
		
577 swalkenh 2352
				<!-- copy all other childs -->
813 swalkenh 2353
				<xsl:for-each select="node()">
2354
					<xsl:if test="not(name(.) = 'RECTANGLE')">
2355
					<xsl:if test="not(name(.) = 'ELLIPSE')">
2356
					<xsl:if test="not(name(.) = 'POLYLINE')">
2357
 
2358
					</xsl:if></xsl:if></xsl:if>
2359
				</xsl:for-each>
2360
		
2361
			</xsl:element>
2362
577 swalkenh 2363
		</xsl:otherwise>
813 swalkenh 2364
	</xsl:choose>
2365
</xsl:template>
2366
2367
<xsl:template match="IMAGE">
2368
	<xsl:choose>
2369
		<xsl:when test="@XMLEditorSavedNameOfNode = 'PHOTO'">
2370
			<xsl:element name="PHOTO">
2371
				<!-- work on attributes and childs -->
2372
				<xsl:attribute name="label">
2373
					<xsl:value-of select="@name" />
2374
				</xsl:attribute>
2375
				<xsl:attribute name="uri">
2376
					<xsl:value-of select="@url" />
2377
				</xsl:attribute>
2378
				<xsl:for-each select="attribute::*">
577 swalkenh 2379
					<xsl:if test="not(name(.) = ('name'))">
813 swalkenh 2380
					<xsl:if test="not(name(.) = ('url'))">
577 swalkenh 2381
					<xsl:if test="not(name(.) = ('XMLEditorSavedNameOfNode'))">
813 swalkenh 2382
						<xsl:attribute name="{name(.)}">
2383
							<xsl:value-of select="self::node()" />
2384
						</xsl:attribute>
577 swalkenh 2385
					</xsl:if></xsl:if></xsl:if>
2386
				</xsl:for-each>
2387
				<xsl:for-each select="node()">
813 swalkenh 2388
 
577 swalkenh 2389
				</xsl:for-each>
2390
			</xsl:element>
813 swalkenh 2391
		</xsl:when>
2392
		
2393
		<xsl:otherwise>
2394
			<xsl:element name="IMAGE">
2395
				<!-- work on attributes and childs -->
577 swalkenh 2396
				<xsl:attribute name="label">
813 swalkenh 2397
 
577 swalkenh 2398
				</xsl:attribute>
2399
 
813 swalkenh 2400
					<xsl:value-of select="@url" />
2401
				</xsl:attribute>
2402
				<xsl:for-each select="attribute::*">
577 swalkenh 2403
 
813 swalkenh 2404
					<xsl:if test="not(name(.) = ('url'))">
2405
						<xsl:attribute name="{name(.)}">
2406
							<xsl:value-of select="self::node()" />
2407
						</xsl:attribute>
2408
					</xsl:if></xsl:if>
2409
				</xsl:for-each>
2410
				<xsl:for-each select="node()">
2411
					<xsl:apply-templates select="." />
2412
				</xsl:for-each>
2413
			</xsl:element>
2414
		</xsl:otherwise>
2415
	</xsl:choose>
2416
</xsl:template>
2417
2418
2419
</xsl:stylesheet>PK
2420
2421
wŽù.	META-INF/þÊPK
2422
2423
wŽù.(\<MM+META-INF/MANIFEST.MFPK
2424
2425
A‰ù.ÓÆ`ö»»/ªsrc/plugins/regionEditorPlugin/ImagePanel.classPK
2426
2427
U|ø.ñù8XÇÇ.²src/plugins/regionEditorPlugin/ImagePanel.javaPK
2428
2429
 
2430
2431
Cù..©Ñ××*§'src/plugins/regionEditorPlugin/Region.javaPK
2432
2433
çù.[èÿ\A\A7Æ/src/plugins/regionEditorPlugin/RegionEditorPlugin.classPK
2434
2435
çù.¯óÝù?a?a6wqsrc/plugins/regionEditorPlugin/RegionEditorPlugin.javaPK
2436
2437
rŽù.ÉkØX$A$A>
2438
Ósrc/plugins/regionEditorPlugin/RegionEditorPluginTransform.xslPK
2439
2440
ðhù.î}ñDñDBŠsrc/plugins/regionEditorPlugin/RegionEditorPluginTransformBack.xslPK
2441
2442
ŒÛY