Subversion Repositories general

Rev

Rev 746 | Blame | Last modification | View Log | RSS feed

PK
wŽù. META-INF/þÊPK
wŽù.(\<MMMETA-INF/MANIFEST.MFManifest-Version: 1.0
Class-Path: ImagePlugin.jar
Transform-To-File: src/plugins/regionEditorPlugin/RegionEditorPluginTr
 ansform.xsl
XMLEditor-Plugin-Name: RegionEditor
Created-By: 1.4.2 (Sun Microsystems Inc.)
Main-Class: src.plugins.regionEditorPlugin.RegionEditorPlugin
Description: ...(todo)
Transform-Fro-File: src/plugins/regionEditorPlugin/RegionEditorPluginT
 ransformBack.xsl
Comment: you can set named regions on pictures

Name: src/plugins/regionEditorPlugin
Specification-Title: plugin for XMLEditor
Implementation-Title: src.plugins.regionEditorPlugin
Specification-Version: 0.4 (05/07/03)
Specification-Vendor: group5, software practice SS_2003, University Bi
 elefeld, Germany
Implementation-Version: 0.1 (05/07/03)
Implementation-Vendor: group5, software practice SS_2003, University B
 ielefeld, Germany

PK
A‰ù.ÓÆ`ö»»/src/plugins/regionEditorPlugin/ImagePanel.classÊþº¾-¡)src/plugins/regionEditorPlugin/ImagePaneljavax/swing/JPanelimageLjava/awt/Image;dxIdy
imageWidthimageHeightcoefDregionsLjava/util/List;selectedRegion'Lsrc/plugins/regionEditorPlugin/Region;<init>(Ljava/util/List;)VCode(Z)V
       LineNumberTableLocalVariableTablethis+Lsrc/plugins/regionEditorPlugin/ImagePanel;paintComponent(Ljava/awt/Graphics;)Vjavax/swing/JComponent getWidth()I"#
!$  getHeight&#
!'java/awt/Component)
getBackground()Ljava/awt/Color;+,
*-java/awt/Graphics/setColor(Ljava/awt/Color;)V12
03fillRect(IIII)V56
07       9java/awt/Image;!(Ljava/awt/image/ImageObserver;)I"=
<>&=
<@java/lang/MathBmax(DD)DDE
CF
       H       J        L
      N       P  drawImage5(Ljava/awt/Image;IIIILjava/awt/image/ImageObserver;)ZRS
0Tjava/awt/ColorVblackLjava/awt/Color;XY        WZwhite\Y       W]
setXORMode_2
0`java/util/Listbget(I)Ljava/lang/Object;decf%src/plugins/regionEditorPlugin/Regionh        jgetRect()Ljava/awt/Rectangle;lm
injava/awt/RectanglepgetX()Drs
qtgetYvs
qw"s
qy&s
q{drawRect}6
0~size€#credƒY     W„gLjava/awt/Graphics;whiwihkxkyiregionrectLjava/awt/Rectangle;setImage(Ljava/awt/Image;)Vrepaint()V”•
*–getCoefgetDxgetDy
getImageWidthgetImageHeightsetSelectedRegion*(Lsrc/plugins/regionEditorPlugin/Region;)V
SourceFileImagePanel.java        

   G*·*+µ±AB
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
§`*´
¹gÀi:*´k¥D¶o:+¶u*´IoŽ*´K`¶x*´IoŽ*´M`¶z*´IoŽ¶|*´IoŽ¶„

*´¹‚¡ÿ˜*´kÆM*´k¶o:
+²…¶4+
¶u*´IoŽ*´K`
¶x*´IoŽ*´M`
¶z*´IoŽ
¶|*´IoŽ¶±ª*KL
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ˆ
t‰+RŠ5H‹=@Œ
E8
¾nŽ
ÑJá:‘<A‘
’“F
*+µ:*¶—±‘   ’

˜s/*´I¯œ™#/*´K¬¦š#/*´M¬°›#/*´O¬¹œ#/*´Q¬Âž>*+µk±
ÍΏŸ PK
U|ø.ñù8XÇÇ.src/plugins/regionEditorPlugin/ImagePanel.java/*
 * This file contains the ImagePanel class.
 *
 * Coded by: Group 5, software practice summer 2003
 * University of Bielefeld, Germany
 *
 * @version $Revision: 1.8 $
 *
 * Last modification: $Date: 2003/07/24 13:34:43 $
 * $Id: ImagePanel.java,v 1.8 2003/07/24 13:34:43 hjokusch Exp $
 */

package src.plugins.regionEditorPlugin;

import java.util.List;

import java.awt.Color;
import java.awt.Rectangle;
import java.awt.Graphics;
import java.awt.Image;

import javax.swing.JPanel;

/**
 * Image panel shows any image.
 *
 * @author Yulia Klassen, Viktoriya Zudova
 *
 * @version $Revision: 1.8 $ Last modification: $Date: 2003/07/24 13:34:43 $
 */
class ImagePanel extends JPanel {

        /** The current image. */
        private Image image;

        /** The dx-shift of an image in relation to the left top corner of plugin panel. */
        private int dx;

        /** The dy-shift of an image in realtion to the left top corner of plugin panel. */
        private int dy;

        /** The width of the image. */
        private int imageWidth;

        /** The height of the image. */
        private int imageHeight;


        /* The scale coef (acronym for coeffiecient)of the image. */
        private double coef;
        
        /** The list of all regions. */
        private List regions;
        
        /** The selected region. */
        private Region selectedRegion;

        /**
         * The class constructor invokes <code>JPanel</code> to create
         * all elements for the options dialog.
         *
         * @see javax.swing.JPanel
         */
        public ImagePanel(List regions) {
                super(true);
                this.regions = regions;
        }

        /**
         * <code>paintComponent</code> draws the image.
         *
         * @see javax.swing.JComponent#paintComponent
         */
        public void paintComponent(Graphics g) {
                int w  = getWidth();
                int h  = getHeight();

                /* Fill the background. */
                g.setColor(getBackground());
                g.fillRect(0, 0, w, h);

                /* If there is an image ... */
                if(image != null) {

                        /* Calculate the size and position of the image. */
                        int iw = image.getWidth(null);
                        int ih = image.getHeight(null);
                        double kx = (double)iw/w;
                        double ky = (double)ih/h;

                        coef = Math.max(kx, ky);

                if(coef < 1) {
                        coef = 1;
                } else {
                        iw = (int)(iw/coef);
                        ih = (int)(ih/coef);
                }

                dx = (w-iw)/2;
                dy = (h-ih)/2;
                imageWidth = iw;
                imageHeight = ih;

                /* Draw the image. */
                g.drawImage(image, dx, dy, iw, ih, null);

                /* Draw regions. */
                g.setColor(Color.black);
                g.setXORMode(Color.white);
                for(int i = 0; i < regions.size(); i++) {
                        Region region = (Region)regions.get(i);

                        if(region != selectedRegion){           // The selected one will be drawn later.
                            Rectangle rect = region.getRect();

                                g.drawRect(
                                        (int)(rect.getX() / coef) + dx,
                                        (int)(rect.getY() / coef) + dy,
                                        (int)(rect.getWidth() / coef),
                                        (int)(rect.getHeight() / coef));
                        }
                        }

                        /* Draw the selected rectangle. */
                        if(selectedRegion != null) {
                            Rectangle rect = selectedRegion.getRect();
                                g.setColor(Color.red);
                                g.drawRect(
                                (int)(rect.getX() / coef) + dx,
                                (int)(rect.getY() / coef) + dy,
                                (int)(rect.getWidth() / coef),
                                (int)(rect.getHeight() / coef));
                        }
                }
        }

        /**
         * Sets the currently visible image to the image given as parameter.
         *
         * @param image: The image to display.
         */
        public void setImage(Image image) {
                this.image = image;
                repaint();
        }


        /**
         * The methode <code> getCoef </code> retuns the double for 
         * scaling the image
         * 
         * @return coef double: the scale (coefficient) for the Image
         */
        public double getCoef() {
                return coef;
        }

        /**
         * Returns the dx-shift of an image according to the left top
         * corner of the plugin panel.
         *
         * @return The difference on the x-axis.
         */
        public int getDx() {
                return dx;
        }

    /**
     * Returns the dy-shift of an image according to the left top
     * corner of the plugin panel.
     *
     * @return The difference on the y-axis.
     */
        public int getDy() {
                return dy;
        }

    /**
     * Returns the width of the current image.
     *
     * @return The width of the current image.
     */
        public int getImageWidth() {
                return imageWidth;
        }

        /**
         * Returns the height of the current image.
         *
         * @return The height of the current image.
         */
        public int getImageHeight() {
                return imageHeight;
        }


        /**
         * The method<code>setSelectedRegion</code> Returns the current selected region in the Image
         * The Region represenrs a specified arey in the picture with a specified name.
         * 
         * @param region the selected src.plugins.regionEditorPlugin.Region
         */ 
        public void setSelectedRegion(Region region) {
                this.selectedRegion = region;
        }
}PK
A‰ù.154_™™+src/plugins/regionEditorPlugin/Region.classÊþº¾-&%src/plugins/regionEditorPlugin/Regionjava/lang/ObjectnameLjava/lang/String;rectLjava/awt/Rectangle;savedNameOfNode<init>()VCode


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
SourceFileRegion.java!   
3*·±
#%
Y*·*+µ*,µ±,.      /0 /*´°8>*+µ±
AB/*´°J>*+µ±
ST /*´"°\#>*+µ"±
ef$%PK
Cù..©Ñ××*src/plugins/regionEditorPlugin/Region.java/*
 * This file contains the Region class.
 *
 * Coded by: Group 5, software practice summer 2003
 * University of Bielefeld, Germany
 *
 * @version $Revision: 1.5 $
 *
 * Last modification: $Date: 2003/07/24 22:18:06 $
 * $Id: Region.java,v 1.5 2003/07/24 22:18:06 ioklasse Exp $
 */

package src.plugins.regionEditorPlugin;

import java.awt.Rectangle;
//import org.w3c.dom.Node;

/**
 * Stores info of one region.
 *
 * @author Yulia Klassen, Viktoriya Zudova
 */
public class Region
{
  /** Stores name of region.*/
  private String name;

  /** Stores coordinates of region. */
  private Rectangle rect;

  /** Stores name of node for the region.*/
  private String savedNameOfNode;

  /** Creates empty region with coordinates and name. */
  public Region()
  {
  }

  /** Construktor creates new region with coordinates and name.
   *
   * @param name: Region name.
   * @param rect: Region coordinates.
   */
  public Region(String name, Rectangle rect)
  {
        this.name = name;
        this.rect = rect;
  }

  /** Returns the name of the region.
   *
   * @return the name of the region.
   */
  public String getName()
  {
        return name;
  }

  /** Sets the name of the region.
   *
   * @param name:  The name of the region.
   */
  public void setName(String name)
  {
        this.name = name;
  }

  /** Returns the coordinates of the region.
   *
   * @return the coordinates of the region.
   */
  public Rectangle getRect()
  {
        return rect;
  }

  /** Sets the coordinates of the region.
   *
   * @param rect: The coordinates of the region.
   */
  public void setRect(Rectangle rect)
  {
        this.rect = rect;
  }

  /** Returns the saved name of node for the region.
   *
   * @return the saved name of node for the region.
   */
  public String getSavedNameOfNode()
  {
        return savedNameOfNode;
  }

  /** Sets the saved name of node for the region.
   *
   * @param name:  The saved name of node for the region.
   */
  public void setSavedNameOfNode(String name)
  {
        this.savedNameOfNode = name;
  }
}
PK
çù.[èÿ\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
pluginNameLjava/lang/String;
ConstantValueRegionEditorimageLjava/awt/Image;imageNameLabelLjavax/swing/JLabel;imageNameFieldLjavax/swing/JTextField;
confirmButtonLjavax/swing/JButton;regionNameLabelregionNameFieldregionConfirmButton
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;
moveCursorresizeCursorinMoveZinResizepopupLjavax/swing/JPopupMenu;deleteSelectedItemLjavax/swing/JMenuItem;<init>()VCode;<
>
       @javax/swing/JLabelB Image Name D(Ljava/lang/String;)V;F
CG       Ijavax/swing/JTextFieldK
L>       Njavax/swing/JButtonPConfirmR
QG       U
 Region Name W    Y       [       ]java/util/ArrayList_
`>,-       bjava/awt/Cursord(I)V;f
eg01       i21       k31       m45       o65       qjavax/swing/JPopupMenus
t>78       vjavax/swing/JMenuItemxDelete the regionz
yG9:       }java/awt/BorderLayout
€>java/awt/Container‚      setLayout(Ljava/awt/LayoutManager;)V„…
ƒ†)src/plugins/regionEditorPlugin/ImagePanelˆ(Ljava/util/List;)V;Š
‰‹     java/awt/ComponentaddMouseListener!(Ljava/awt/event/MouseListener;)V‘’
“addMouseMotionListener'(Ljava/awt/event/MouseMotionListener;)V•–
—West™add)(Ljava/awt/Component;Ljava/lang/Object;)V›œ
ƒ*(Ljava/awt/Component;)Ljava/awt/Component;›Ÿ
ƒ East¢java/awt/Dimension¤(II)V;¦
¥§javax/swing/JComponent©setPreferredSize(Ljava/awt/Dimension;)V«¬
ª­North¯javax/swing/AbstractButton±addActionListener"(Ljava/awt/event/ActionListener;)V³´
²µ0(Ljavax/swing/JMenuItem;)Ljavax/swing/JMenuItem;›·
t¸
setVisible(Z)Vº»
ª¼LineNumberTableLocalVariableTablethis3Lsrc/plugins/regionEditorPlugin/RegionEditorPlugin;    leftPanelLjavax/swing/JPanel;
rightPaneltopPanelinit(Lsrc/gui/GuiInterface;)V    ÈstartF(Lorg/w3c/dom/Node;Lorg/w3c/dom/Document;Ljavax/swing/tree/TreePath;)V*+     Ì'(      Îsrc/gui/GuiInterfaceÐgetStatusInterface()Lsrc/gui/StatusInterface;ÒÓÑÔsrc/gui/StatusInterfaceÖsetIconØf×Ù
setMessageÛF×ÜsetPoint(Ljava/awt/Point;)VÞß×à#     âorg/w3c/dom/Nodeä
getAttributes()Lorg/w3c/dom/NamedNodeMap;æçåèorg/w3c/dom/NamedNodeMapëgetNamedItem&(Ljava/lang/String;)Lorg/w3c/dom/Node;íîìïgetNodeValue()Ljava/lang/String;ñòåójavax/swing/text/JTextComponentõsetText÷F
öø        findImageú<
ûinitRegions(Lorg/w3c/dom/Node;)Výþ
ÿsetPluginPanel(Ljavax/swing/JPanel;)VÑnodeelementPathLjavax/swing/tree/TreePath;getDocumentManagerInterface(()Lsrc/control/DocumentManagerInterface;     Ñ
$src/control/DocumentManagerInterfacegetPluginManagerInterface&()Lsrc/plugins/PluginManagerInterface;
org/w3c/dom/DocumentgetDocumentElement()Lorg/w3c/dom/Element;findUrlForImageName\(Lsrc/plugins/PluginManagerInterface;Ljava/lang/String;Lorg/w3c/dom/Node;)Ljava/lang/String;
$       getLogInterface()Lsrc/gui/LogInterface;Ñ java/lang/StringBuffer"      Picture "$
#Gappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;'(
#)"+ not found in document.-toString/ò
#0src/gui/LogInterface2log(ILjava/lang/String;)V4536       loadImage8F
9org/w3c/dom/Element;getNodeName=òå>"src/plugins/PluginManagerInterface@getAssociatedPlugin&(Ljava/lang/String;)Ljava/lang/String;BCADImageViewerFjava/lang/StringHequals(Ljava/lang/Object;)ZJK
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}~
|ywƒh…#text‡trim‰ò
IŠŒ%src/plugins/regionEditorPlugin/RegionŽjava/awt/Rectangle(IIII)V;’
‘“)(Ljava/lang/String;Ljava/awt/Rectangle;)V;•
–setSavedNameOfNode˜F
™›Ko›java/lang/NumberFormatExceptionchildrenrectNoderectChildrensavedNameOfNodejsubnodeattrsex!Ljava/lang/NumberFormatException;valueregion       printTree(Lorg/w3c/dom/Node;I)Vjava/lang/System¬outLjava/io/PrintStream;®¯  ­°1=================================================²java/io/PrintStream´println¶F
µ· ¹print»F
µ¼valueOf&(Ljava/lang/Object;)Ljava/lang/String;¾¿
IÀ:Âì^="Åìb [È]Ê¶<
µÌª«
ÎindentstopsetOurEventListener!(Lsrc/control/OurEventListener;)V!"    ÔnewListenerforceStatusReport       cloneNode(Z)Lorg/w3c/dom/Node;ØÙåÚ)(    ÜgetOwnerDocument()Lorg/w3c/dom/Document;ÞßåàsetNodeValueâFåãiterator()Ljava/util/Iterator;åæoçjava/util/Iteratorénext()Ljava/lang/Object;ëìêígetNameïò
ðcreateTextNode&(Ljava/lang/String;)Lorg/w3c/dom/Text;òóô
createElement)(Ljava/lang/String;)Lorg/w3c/dom/Element;ö÷øgetSavedNameOfNodeúò
ûsetAttribute'(Ljava/lang/String;Ljava/lang/String;)Výþ<ÿgetRect()Ljava/awt/Rectangle;
ym      ‘(I)Ljava/lang/String;/
|m      ‘
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
tempDocLjava/util/Iterator;Lorg/w3c/dom/Text;geomLorg/w3c/dom/Element;coordssrc/control/OurEvent$java/lang/Object&([Ljava/lang/Object;)V;(
%)src/control/OurEventListener+
firedOurEvent(Lsrc/control/OurEvent;)V-.,/eLsrc/control/OurEvent;%&  3       5No image7getCurrentFile()Ljava/io/File;9:Ñ;java/io/File=
getParentFile?:
>@
>0
startsWith(Ljava/lang/String;)ZCD
IE/GreplaceFirst8(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;IJ
IKcharAt(I)CMN
IO
>G#(Ljava/io/File;Ljava/lang/String;)V;R
>Sjavax/imageio/ImageIOUread.(Ljava/io/File;)Ljava/awt/image/BufferedImage;WX
VYShow image from [Cannot open file ]setImage(Ljava/awt/Image;)V_`
‰ajava/io/IOExceptioncfileNamedocLjava/io/IOException;actionPerformed(Ljava/awt/event/ActionEvent;)Vjava/util/EventObjectj       getSourcelì
kmgetTextoò
öp×<
r./       tsetNamevF
wdeleteRegion*(Lsrc/plugins/regionEditorPlugin/Region;)Vyz
{Ljava/awt/event/ActionEvent;mouseDragged(Ljava/awt/event/MouseEvent;)Vjava/awt/event/MouseEvent€getX‚a
ƒgetY…a
†        showMouseˆ¦
‰getDx‹a
‰ŒgetCoef()DŽ
‰getDy’a
‰“getWidth•
‘–java/awt/Image˜!(Ljava/awt/image/ImageObserver;)I•š
™›        getHeight
‘žš
™ setLocation¢¦
‘£repaint¥<
¦‚
‘¨…
‘ªsetSize¬¦
‘­setSelectedRegion¯z
° addRegion²z
³Ljava/awt/event/MouseEvent;rectLjava/awt/Rectangle;D
mouseMoved
findRegion,(IIZ)Lsrc/plugins/regionEditorPlugin/Region;º»
¼ setCursor(Ljava/awt/Cursor;)V¾¿
Àregion1region2
getImageWidthÄa
‰ÅgetImageHeightÇa
‰Èjava/awt/PointÊ
˧mouseXmouseYxxyymouseClickedselectRegionҦ
ÓmousePressedisPopupTriggerÖ
×        showPopupÙ¦
Ú
mouseReleasedmouseEnteredmouseExitedremoveßKoàget(I)Ljava/lang/Object;âãoäcontains(II)Zæç
‘èsizeêaoëjava/lang/Mathíabs(I)Iïð
îñnordWest
currentRegion
setEnabledõ»
yöshow(Ljava/awt/Component;II)Vøù
tú
‰°
SourceFileRegionEditorPlugin.java!

 !"#$%&'()(*+,-./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
NQ"T/W<ZG]T{_k„x‡„Š‰Ž™“¦™±œÀÈžÐ¡Ø¢ã£í¤ö¥¨©ª#«-¬6­@°H±S²Y³`µg¶p¸x¹€¼ˆ½”¿™À¿*šÀÁØÂÂÃ’ÄÃHRÅÃÆÇ=>*+µÉ±¾
ÈÉ¿ÀÁ ÊË=ù}*,µÍ*+µÏ*´É¹Õ¹Ú*´É¹Õ¹Ý*´É¹Õ¹á+Ç*µã§*+¹éê¹ð¹ôµã*´O*´ã¶ù*·ü*+·*´É*¹*¶½±¾:×Ø
ÚÛ(Ü7Þ;ßCáYãdähçméwê|ë¿*}ÀÁ}(}*+}ú<=°b***´É¹¹*´ã*´Í¹·µ*´Ç2*´É¹!»#Y%·&*´ã¶*,¶*.¶*¶1¹7**´·:±¾*
òòóô#ö*÷4øT÷Yûaü¿bÀÁ=€      °-Á<š°+-¹?¹E:Æ_G¶M™T+-¹Q:ÆD¹é:S¹ð¹ô:U¹ð¹ô:Æ,¶M™Æ°-¹Y:6§*+,¹_·:Æ°„¹c¡ÿÛ°¾>
       '27@Qbx€†—"Ÿ®&¿z°ÀÁ°de°#°(™f2Fg(@8hiQ'RbT€0jkƒ+lm—Týþ=©  Q*´c¹r+¹YM>§4,¹_:¹?t¶M™¹Y:6666      :
:6§¾¹_:

¹?v¶M™u
¹é:x¹ð¹ô:z¹ð¹ô¸€6‚¹ð¹ô¸€6„¹ð¹ô¸€6†¹ð¹ô¸€6    §3:§.
¹?ˆ¶M™
¹ô¶‹:¶Mš:
„¹c¡ÿ<»Y
»‘Y   ·”·—:¶š*´c¹œW„,¹c¡þȱ„×מ¾‚ 0 2346.778:9=:@;C<F=I?O@ZCjDsG‚F„J˜K¬LÀM×OÜSìTøV?Z0[7\C3P_¿¶QÀÁQ(AŸk>lm% (7¡k:       ym=m@ƒmC…m  FýR
Iú¢LÊ£mZ­¤(
si¥iÙ¦§ø¨0©/ª«=éš²±³¶¸+¹?N+¹é:+¹Y:6§²±º¶½„h¡ÿï²±»#Y-¸Á·&ö*¶1¶½ÆY6§G²±»#Yº·&¹Ä¹?¶*ƶ*¹Ä¹ô¶*,¶*¶1¶½„¹Ç¡ÿ³+¹ôÆ%²±»#YÉ·&+¹ô¶*˶*¶1¶½²±¶Í6§*¹_`·τ¹c¡ÿäš²±³¶¸±¾^de
ghi$l>oXr]sctft‡užt¤s³y¼zÞ{ä~êú~       
‚ƒ¿\   ÀÁ(ÐmRû¥i$ójk'lm`Slmç"lmÑ<=m3*¶½*´É¹Õ¹Ú*´É¹Õ¹Ý*´É¹Õ¹á±¾Ž#2‘¿3ÀÁÒÓ=>*+µÕ±¾
—˜¿ÀÁÖ"×<=â$**´Ï¹ÛµÝ*´Ï¹á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}~=}
;+¶n*´Ž¦2*´6Æ+*+¶„+¶‡¶Š*´p™±*´uƪ*´u¶M+¶„*´Ž¶d‡*´Ž¶‘kJ+¶‡*´Ž¶”d‡*´Ž¶‘k9)˜œJ˜œ9),¶—Ž‡c*´6¶œ‡—›*´6¶œ,¶—Ždd‡J,¶ŸŽ‡c*´6¶¡‡—›*´6¶¡,¶ŸŽdd‡9,)ŽŽ¶¤*¶§§j*´r™²*´uÆ«*´u¶M+¶„*´Ž¶d‡*´Ž¶‘kJ+¶‡*´Ž¶”d‡*´Ž¶‘k9),¶©g9,¶«g9   ˜œ9   ˜œ9       )*´6¶œ‡—›*´6¶œ‡,¶©g9*´6¶¡‡—›*´6¶¡‡,¶«g9    ,Ž  Ž¶®*¶§§´+¶„*´Ž¶d‡*´Ž¶‘kI+¶‡*´Ž¶”d‡*´Ž¶‘k9(—›—›z(*´6¶œ‡˜œl*´6¶¡‡˜œ]*µr»Y»‘Y+¶„*´Ž¶d‡*´Ž¶‘kŽ+¶‡*´Ž¶”d‡*´Ž¶‘kŽ·”·—:v¶š*·±**´u¶´±¾¦),4Ja!i"s$ˆ%š&°'Ã)Ì*Ó,á-é.ÿ/01'314;6I7Y8h9x;‚<‰?Ÿ@¶BàCåDêDîEFD$G,H2I:M¿„
;ÀÁ;1µ4Ÿ¶·J‰y¸ar¸é ¶·ÿŠy¸s¸kƒ¸'b…¸     Ÿ›y¸¶„¸$©/¹=Ía+¶n*´Ž¦X*´6ÆQ*+¶„+¶‡¶Š*+¶„+¶‡·½M,Æ**´l¶Á§(*+¶„+¶‡·½N-Æ**´n¶Á§**´j¶Á±¾*
VWY,[0\;_IaMbXe`i¿*aÀÁa1µ,4Â/IÃ/ˆ¦=|*´Ž¶d>*´Ž¶”d6››*´Ž¶Æ£*´Ž¶ɤ*´É¹Õ¹á§7‡*´Ž¶‘kŽ6‡*´Ž¶‘kŽ6*´É¹Õ»ËY·̹á±¾&        s
tv)w5yG|T}b{¿H|ÀÁ|Ím|Îm
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š
*´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¹ì¡ÿ˱¾*
ÿ).4DRX        [l¿HmÀÁmymmmYÏm)DÐm1;lmD©/º»=…
Á*´Ž¶d‡*´Ž¶‘kŽ6*´Ž¶”d‡*´Ž¶‘kŽ6:6§€*´c¹åÀ:¶:      ™-  ¶©Žd¸ò¢R   ¶«Žd¸ò¢B:§L§8       ¶©Ž        ¶—Ž`d¸ò¢!  ¶«Ž        ¶ŸŽ`d¸ò¢
:§„*´c¹ì¡ÿx°¾F*-3 C!J#N$^%n'r(x,-¦/ª0­¾5¿f
ÁÀÁÁymÁmÁó5¬Ïm*—Ðm-”ô/0ŽlmCj©/Jc¶·   Ù¦=v(*·Ô*¶§*´~*´uƧ¶÷*´w*¶û±¾@A
DE'F¿ (ÀÁ(ym(m¯z=x0*+µu*´Ž+¶ü*´uÇ*´\¶ù§*´\*´u¶ñ¶ù±¾NO
QR!T/U¿0ÀÁ0©/ýþPK
çù.¯óÝù?a?a6src/plugins/regionEditorPlugin/RegionEditorPlugin.java/*
 * This file contains the RegionEditorPlugin class.
 *
 * Coded by: Group 5, software practice summer 2003
 * University of Bielefeld, Germany
 *
 * @version $Revision: 1.28 $
 *
 * Last modification: $Date: 2003/07/24 22:18:06 $
 * $Id: RegionEditorPlugin.java,v 1.28 2003/07/24 22:18:06 ioklasse Exp $
 */

package src.plugins.regionEditorPlugin;

import java.util.ArrayList;
import java.util.List;
import java.util.Iterator;

import java.awt.BorderLayout;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

import java.io.File;
import java.io.IOException;

import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;

import org.w3c.dom.NodeList;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.Text;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.tree.TreePath;


import src.control.OurEvent;
import src.control.OurEventListener;
import src.gui.*;
import src.plugins.PluginInterface;
import src.plugins.PluginManagerInterface;



/**
 * The <code>RegionEditor</code> plugin shows and edits image regions.
 *
 * @author Yulia Klassen, Viktoriya Zudova
 *
 * @version $Revision: 1.28 $ Last modification: $Date: 2003/07/24 22:18:06 $
 */
public class RegionEditorPlugin
  extends JPanel
  implements PluginInterface, ActionListener, MouseMotionListener, MouseListener
{
  /** Name of the plugin, used in method <code>firePluginChangedElement</code> */
  final private String pluginName = "RegionEditor";

  /** The current image. */
  private Image image;

  /** Label where the name of image is. */
  private JLabel imageNameLabel = new JLabel(" Image Name ");

  /** A text field to enter the name of an image. */
  private JTextField imageNameField = new JTextField();

  /** A button "Confirm" to change the image name in the node. */
  private JButton confirmButton = new JButton("Confirm");

  /** Label where the name of region is. */
  private JLabel regionNameLabel = new JLabel(" Region Name ");

  /** A text field to enter the name of region. */
  private JTextField regionNameField = new JTextField();

  /** A button "Confirm" to change the region name. */
  private JButton regionConfirmButton = new JButton("Confirm");

  /** An image panel to show an image in. */
  private ImagePanel imagePanel;

  /** Stores a reference to the GUI. */
  private GuiInterface gui;

  /** Stores a reference to the event listener. */
  private OurEventListener ourEventListener;

  /** The image's name from the attributes of the selected node. */
  private String imageName;

  /** The location of the image. */
  private String imageUrl;

  /** The current file. */
  private File currentFile;

  /** The node given from the basis program. */
  private Node oldNode;

  /** The node returned to the basis program. */
  private Node changedNode;

  /** The document */
  private Document environment;

  /** The list of all regions. */
  private List regions = new ArrayList();

  /** The selected region. */
  private Region selectedRegion;

  /** The normal cursor. */
  private Cursor normalCursor = new Cursor(Cursor.DEFAULT_CURSOR);

  /** The moving cursor. */
  private Cursor moveCursor = new Cursor(Cursor.MOVE_CURSOR);

  /** The resizing cursor. */
  private Cursor resizeCursor = new Cursor(Cursor.SE_RESIZE_CURSOR);

  /** The moving flag: true if some region is moving at the moment. */
  private boolean inMove = false;

  /** The resizing flag: true if some region is resizing at the moment. */
  private boolean inResize = false;

  /** The region popup menu. */
  private JPopupMenu popup = new JPopupMenu();

  /** The popup menu item to delete the region. */
  private JMenuItem deleteSelectedItem = new JMenuItem("Delete the region");

  /** The class constructor creates all elements for the RegionEditor plugin. */
  public RegionEditorPlugin() {

    // Sets new layout.
    setLayout(new BorderLayout());

    // Creates the image panel.
    imagePanel = new ImagePanel(regions);
    imagePanel.addMouseListener(this);
    imagePanel.addMouseMotionListener(this);

    // Left panel: text field to enter name of image.
    JPanel leftPanel = new JPanel();
    leftPanel.setLayout(new BorderLayout());
        leftPanel.add(imageNameLabel, BorderLayout.WEST);
    leftPanel.add(imageNameField);
    leftPanel.add(confirmButton, BorderLayout.EAST);

    // Right panel: label to show name of region
    JPanel rightPanel = new JPanel();
    rightPanel.setPreferredSize(new Dimension(240, 24));
    rightPanel.setLayout(new BorderLayout());
        rightPanel.add(regionNameLabel, BorderLayout.WEST);
    rightPanel.add(regionNameField);
    rightPanel.add(regionConfirmButton, BorderLayout.EAST);

    // Top panel contains left and right panels.
    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BorderLayout());
    topPanel.add(leftPanel);
    topPanel.add(rightPanel, BorderLayout.EAST);

    add(topPanel, BorderLayout.NORTH);
    add(imagePanel);

    confirmButton.addActionListener(this);
    regionConfirmButton.addActionListener(this);

    // Init popup menu.
    deleteSelectedItem.addActionListener(this);
    popup.add(deleteSelectedItem);

    setVisible(false);
  }

        /**
         * Initializes the plugin.
         *
         * @param gui: A reference to the GUI object.
         */
        public void init(GuiInterface gui) {
            this.gui = gui;
        }

        /**
         * Starts the plugin.
         *
         * @param node: The node that the has been chosen.
         * @param environment: The current document.
         * @param elementPath: The <code>TreePath</code> of the selected
         * node in the evironment.
         *
         * @see src.plugins.PluginInterface#start
         */
        public void start(Node node, Document environment, TreePath elementPath)
        {
        this.environment = environment;
        oldNode = node;
//      changedNode = node;
        gui.getStatusInterface().setIcon(StatusInterface.ICON_NONE);
        gui.getStatusInterface().setMessage(null);
        gui.getStatusInterface().setPoint(null);

        if (node == null)
          imageName = null;
        else
          imageName = node.getAttributes().getNamedItem("image").getNodeValue();

        imageNameField.setText(imageName);
        findImage();

        // Load existing regions.
        initRegions(node);

            gui.setPluginPanel(this);
                setVisible(true);
        }

    /**
     * Finds image URL and loads it.
     */
    private void findImage()
    {
                imageUrl = findUrlForImageName(
                  gui.getDocumentManagerInterface().getPluginManagerInterface(),
                  imageName, environment.getDocumentElement());

        if (imageUrl==null) {
                gui.getLogInterface().log(LogInterface.TYPE_ERROR,
                  "Picture " + "\"" + imageName + "\"" + " not found in document.");
        }

        loadImage(imageUrl);
    }

        /**
         * Tries to find image URL for label of the image in given node.
         *
         * @param manager: The plugin manager.
         * @param imageName: The name of the image.
         * @param node: The node.
         * @return The URL or null if it can not be found
         */
    private String findUrlForImageName(PluginManagerInterface manager,
      String imageName, Node node)
    {
        // check elements only
        if(!(node instanceof Element)) return null;

            String associatedPlugin = manager.getAssociatedPlugin(node.getNodeName());

            // if this node corresponds to the image viewer - check image name
            if(associatedPlugin != null && associatedPlugin.equals("ImageViewer")) {
              Node transformedNode = manager.transformsNode(associatedPlugin, node);
              if(transformedNode != null) {
                NamedNodeMap nodeAttr = transformedNode.getAttributes();
                    String name = nodeAttr.getNamedItem("name").getNodeValue();
                    String url = nodeAttr.getNamedItem("url").getNodeValue();

                    // if the name matchs the image name we are looking for and
                    // the image has an URL - return the URL
                    if(name != null && name.equals(imageName) && url != null) return url;
                  }
            }

            // if nothing found - try the children
        NodeList list = node.getChildNodes();
        for(int i = 0; i < list.getLength(); i++) {
          String url = findUrlForImageName(manager, imageName, list.item(i));

          // if url found - return it immediately
          if(url != null) return url;
        }

        // nothing found in children
        return null;
        }

        /**
         * Reads the existent regions from document.
         *
         * @param node: The node that the has been chosen.
         */
    private void initRegions(Node node)
    {
      regions.clear();

      NodeList children = node.getChildNodes();
      for(int i = 0; i < children.getLength(); i++) {
        Node rectNode = children.item(i);

        if(rectNode.getNodeName().equals("RECTANGLE")) {
          NodeList rectChildren = rectNode.getChildNodes();
          int x = 0;
          int y = 0;
          int w = 1;
          int h = 1;
          String name = null;
          String savedNameOfNode = null;

          for(int j = 0; j < rectChildren.getLength(); j++) {
            Node subnode = rectChildren.item(j);

            // Get coordinates.
            if(subnode.getNodeName().equals("COORDS")) {
              NamedNodeMap attrs = subnode.getAttributes();

              savedNameOfNode
                = attrs.getNamedItem("XMLEditorSavedNameOfNode").getNodeValue();

              try {
                x = Integer.parseInt(attrs.getNamedItem("x").getNodeValue());
                y = Integer.parseInt(attrs.getNamedItem("y").getNodeValue());
                w = Integer.parseInt(attrs.getNamedItem("w").getNodeValue());
                h = Integer.parseInt(attrs.getNamedItem("h").getNodeValue());
              }
              catch(NumberFormatException ex) {
                // Ignore any errors in coordinates.
              }
            }
            else if(subnode.getNodeName().equals("#text")) {
              String value = subnode.getNodeValue().trim();

              if(!value.equals("")) name = value;
            }
          }

          Region region = new Region(name, new Rectangle(x, y, w, h));
          region.setSavedNameOfNode(savedNameOfNode);
          regions.add(region);
        }
      }
    }

// debug only !!! delete it in the release
private void printTree(Node node, int indent)
{
  if(indent == 0)
    System.out.println("=================================================");

  String name = node.getNodeName();
  NamedNodeMap attrs = node.getAttributes();
  NodeList list = node.getChildNodes();

  // indent
  for(int i = 0; i < indent*2; i++) System.out.print(" ");

  // name
  System.out.print(name + ":");

  // attributes
  if(attrs != null) {
    for(int i = 0; i < attrs.getLength(); i++)
      System.out.print(" " + attrs.item(i).getNodeName() + "=\""
        + attrs.item(i).getNodeValue() + "\"");
  }

  // value
  if(node.getNodeValue() != null)
    System.out.print(" [" + node.getNodeValue() + "]");
  System.out.println();

  // children
  for(int i = 0; i < list.getLength(); i++)
    printTree(list.item(i), indent+1);

  if(indent == 0)
    System.out.println("=================================================");
}


        /**
         * Stops the plugin by setting it to invisible and resetting the display of the
         * status panel.
         *
         * @see src.plugins.PluginInterface#stop
         */
        public void stop() {
            setVisible(false);
        gui.getStatusInterface().setIcon(StatusInterface.ICON_NONE);
        gui.getStatusInterface().setMessage(null);
        gui.getStatusInterface().setPoint(null);
        }

        /* (non-Javadoc)
         * @see src.gui.PluginInterface#setOurEventListener(src.control.OurEventListener)
         */
        public void setOurEventListener(OurEventListener newListener) {
                ourEventListener = newListener;
        }

        /**
         * Forces the plugin to report its status.
         */
        public void forceStatusReport() {
                changedNode = oldNode.cloneNode(false);
                Document tempDoc = oldNode.getOwnerDocument();
                changedNode.getAttributes().getNamedItem("image").setNodeValue(imageName);

printTree(oldNode, 0);
                Iterator i = regions.iterator();
                while(i.hasNext()) {
                        Region region = (Region)i.next();
                        Text name = tempDoc.createTextNode(region.getName());
                        org.w3c.dom.Element geom = tempDoc.createElement("RECTANGLE");
                        org.w3c.dom.Element coords = tempDoc.createElement("COORDS");

                        //modified 25.07.2003 Sascha W.
                        /* attribute "XMLEditorSavedNameOfNode" should only appear if the original
                         * node was not a "COORDS", cause during transformation this attribute is
                         * simply copied if it doesn't contains a proper name */
                        if ((region.getSavedNameOfNode() != null) && (region.getSavedNameOfNode() != "")) {
                                coords.setAttribute("XMLEditorSavedNameOfNode", region.getSavedNameOfNode());
                        }
                        
                        coords.setAttribute("x", Integer.toString(region.getRect().x));
                        coords.setAttribute("y", Integer.toString(region.getRect().y));
                        coords.setAttribute("w", Integer.toString(region.getRect().width));
                        coords.setAttribute("h", Integer.toString(region.getRect().height));
                        geom.appendChild(name);
                        geom.appendChild(coords);
                        changedNode.appendChild((Node)geom);
                }
printTree(changedNode, 0);

                firePluginChangedElement(oldNode, changedNode);
        }

        /**
         * ...
         *
         * @param oldNode: ...
         * @param changedNode: ..
         */
        private void firePluginChangedElement(Node oldNode, Node changedNode) {
                OurEvent e = new OurEvent(new Object[] {oldNode, changedNode, pluginName});
                ourEventListener.firedOurEvent(e);
        }

  /**
   *  Loads image.
   *
   *  @param fileName:   The file name that must be shown:
   */
  private void loadImage(String fileName)
  {
    //  File is absent.
    currentFile = null;

    // File name is absent: status panel - "No image".
    if(fileName == null) {
      image = null;
      gui.getStatusInterface().setIcon(StatusInterface.ICON_WARNING);
      gui.getStatusInterface().setMessage("No image");
    }
    // Gets the current file from the directory where the doc is.
    else {
      try {
        File doc = gui.getCurrentFile();
        if(fileName.startsWith(doc.getParentFile().toString())) {
          fileName = fileName.replaceFirst(doc.getParentFile().toString() + "/", "");
        }

        if(fileName.charAt(0) == '/')
          currentFile = new File(fileName);
        else {
          currentFile = new File(doc.getParentFile(), fileName);
        }

        image = javax.imageio.ImageIO.read(currentFile);
        gui.getStatusInterface().setIcon(StatusInterface.ICON_INFORMATION);
        gui.getStatusInterface().setMessage("Show image from " + fileName);
      }
      catch(IOException ex) {
        gui.getLogInterface().log(
        LogInterface.TYPE_ERROR, "Cannot open file " + fileName);
        gui.getStatusInterface().setIcon(StatusInterface.ICON_ERROR);
        gui.getStatusInterface().setMessage("Cannot open file " + fileName);
      }
    }

    imagePanel.setImage(image);
  }

  /**
   *  Reaction of all buttons.
   *
   *  @param e:  Some event.
   */
  public void actionPerformed(ActionEvent e)
  {
    if(e.getSource() == confirmButton) {
      imageName = imageNameField.getText();
      forceStatusReport();
      findImage();
    }

    if(e.getSource() == regionConfirmButton) {
      if(selectedRegion != null) {
        selectedRegion.setName(regionNameField.getText());
        forceStatusReport();
      }
    }

    if(e.getSource() == deleteSelectedItem) {   // delete the selected region
      deleteRegion(selectedRegion);
      forceStatusReport();
    }
  }


  /**
   * Invoked when a mouse is pressed on a component.
   *
   * @param e:   Mouse event.
   */
  public void mouseDragged(MouseEvent e)
  {
    if(e.getSource() == imagePanel && image != null) {
      showMouse(e.getX(), e.getY());

      if(inMove && selectedRegion != null) {  // Move selected region.
        Rectangle rect = selectedRegion.getRect();
        double x = (e.getX() - imagePanel.getDx()) * imagePanel.getCoef();
        double y = (e.getY() - imagePanel.getDy()) * imagePanel.getCoef();

        if(x < 0) x = 0;
        if(y < 0) y = 0;

        if(x + (int)rect.getWidth() >= image.getWidth(null))
          x = image.getWidth(null) - (int)rect.getWidth() - 1;
        if(y + (int)rect.getHeight() >= image.getHeight(null))
          y = image.getHeight(null) - (int)rect.getHeight() - 1;

        rect.setLocation((int)x, (int)y);
        repaint();
      }
      else if(inResize && selectedRegion != null) {  // Resize selected region.
        Rectangle rect = selectedRegion.getRect();
        double x = (e.getX() - imagePanel.getDx()) * imagePanel.getCoef();
        double y = (e.getY() - imagePanel.getDy()) * imagePanel.getCoef();
                double w = x - rect.getX();
                double h = y - rect.getY();

        if(w < 1) w = 1;
        if(h < 1) h = 1;

        if(x >= image.getWidth(null))
          w = image.getWidth(null) - rect.getX();
        if(y >= image.getHeight(null))
          h = image.getHeight(null) - rect.getY();

        rect.setSize((int)w, (int)h);
        repaint();
      }
      else {   // Creates a new region.
                double x = (e.getX() - imagePanel.getDx()) * imagePanel.getCoef();
                double y = (e.getY() - imagePanel.getDy()) * imagePanel.getCoef();

        if(x >= 0 && y >= 0 && x < image.getWidth(null) && y < image.getHeight(null)) {
          inResize = true;
          Region region = new Region(null, new Rectangle(
            (int)((e.getX() - imagePanel.getDx()) * imagePanel.getCoef()),
            (int)((e.getY() - imagePanel.getDy()) * imagePanel.getCoef()), 1, 1));
          region.setSavedNameOfNode("COORDS");
          setSelectedRegion(region);
          addRegion(selectedRegion);
        }
      }
    }
  }

  /**
   * Invoked when the mouse has been moved on a component (with no buttons no down).
   *
   * @param e:   Mouse event.
   */
  public void mouseMoved(MouseEvent e)
  {
    if(e.getSource() == imagePanel && image != null) {
      showMouse(e.getX(), e.getY());

      Region region1 = findRegion(e.getX(), e.getY(), true);  // Try move.

      if(region1 != null) {    // Found one.
        setCursor(moveCursor);
      }
      else {                 // Not found - try resize.
        Region region2 = findRegion(e.getX(), e.getY(), false);

        if(region2 != null) {    // Found one.
          setCursor(resizeCursor);
        }
        else {                 // Nothing found.
          setCursor(normalCursor);
        }
      }
    }
  }

  /**
   * Shows the current position of mouse.
   *
   * @param mouseX: Position of mouse.
   * @param mouseY: Position of mouse.
   */
  public void showMouse(int mouseX, int mouseY)
  {
    int x = mouseX - imagePanel.getDx();
    int y = mouseY - imagePanel.getDy();

    if(x < 0 || y < 0 || x > imagePanel.getImageWidth()
      || y > imagePanel.getImageHeight())
    {
      gui.getStatusInterface().setPoint(null);
    }
    else {
      int xx = (int)(x * imagePanel.getCoef());
      int yy = (int)(y * imagePanel.getCoef());

      gui.getStatusInterface().setPoint(new Point(xx, yy));
    }
  }

        /**
         * Invoked when the mouse has been clicked on a component.
         *
         * @param e: A mouse event indicating that a mouse button has been
         * clicked on a component.
         */
        public void mouseClicked(MouseEvent e) {
            if(e.getSource() == imagePanel && image != null) {
                selectRegion(e.getX(), e.getY());
                repaint();
        }
        }

  /**
   * Invoked when a mouse has been pressed on a Component.
   *
   * @param e:   Mouse event.
   */
  public void mousePressed(MouseEvent e)
  {
    if(e.getSource() == imagePanel && image != null) {
      if(e.isPopupTrigger()) {           // Show popup.
        showPopup(e.getX(), e.getY());
      }
      else {                             // Test for move/resize.
        Region region1 = findRegion(e.getX(), e.getY(), true);  // Try move.

        if(region1 != null) {    // Found one.
          setCursor(moveCursor);
          setSelectedRegion(region1);
          inMove = true;
        }
        else {                 // Not found - try resize.
          Region region2 = findRegion(e.getX(), e.getY(), false);

          if(region2 != null) {    // Found one.
            setCursor(resizeCursor);
            setSelectedRegion(region2);
            inResize = true;
          }
          else {                 // Nothing found.
            setCursor(normalCursor);
          }
        }
      }
    }
  }

        /**
         * Invoked when a mouse has been released on a component.
         *
         * @param e: A mouse event indicating that a mouse button has been
         * pressed on a component.
         */
        public void mouseReleased(MouseEvent e) {

                /* If the event was fired by the image panel and an image is available ... */
                if(e.getSource() == imagePanel && image != null) {
                if(e.isPopupTrigger()) {
                        showPopup(e.getX(), e.getY());
                }

          // if a region was moved or resized - update the document
          if(inMove || inResize)
            forceStatusReport();

              inMove = false;
          inResize = false;
                }
        }

        /**
         * Empty method needed to implement the <code>MouseListener</code> interface.
         *
         * @see java.awt.event.MouseListener#mouseEntered
         */
        public void mouseEntered(MouseEvent e) {
        }

        /**
         * Invoked when the mouse exits a component. Will reset the point display
         * int the status panel.
         *
         * @param e: A mouse event indicating that the cursor has left a component.
         *
         * @see java.awt.event.MouseListener#mouseExited
         */
        public void mouseExited(MouseEvent e) {
            if(e.getSource() == imagePanel) {
                        gui.getStatusInterface().setPoint(null);
        }
        }

  /**
   *  Adds new region.
   *
   * @param region:    Add the given region.
   */
  public void addRegion(Region region)
  {
    regions.add(region);
    repaint();
  }

  /**
   * Delets a region.
   *
   * @param region:    Delete the given region.
   */
  public void deleteRegion(Region region)
  {
    if(selectedRegion == region) setSelectedRegion(null); // If it was the selected one.
    regions.remove(region);
    repaint();
  }

  /**
   * Selects a region.
   *
   * @param x:   Point of region that the user will select.
   * @param y:   Point of region that the user will select.
   */
  private void selectRegion(int x, int y)
  {
    int xx = (int)((x - imagePanel.getDx()) * imagePanel.getCoef());
    int yy = (int)((y - imagePanel.getDy()) * imagePanel.getCoef());

    setSelectedRegion(null); // Reset old selection.

    for(int i = 0; i < regions.size(); i++) {
      Region region = (Region)regions.get(i);

      if(region.getRect().contains(xx, yy)) { // Found one.
        setSelectedRegion(region);
        break;
      }
    }
  }

  /**
   * Finds region that must be moved or resized.
   *
   * @param x: Position of mouse.
   * @param y: Position of mouse.
   * @param nordWest: If true then top left of corner will be serched,
   * else bottom right  of corner will be serched.
   *
   * @return currentRegion or null if nothing was found.
   */
  private Region findRegion(int x, int y, boolean nordWest)
  {
    int xx = (int)((x - imagePanel.getDx()) * imagePanel.getCoef());
    int yy = (int)((y - imagePanel.getDy()) * imagePanel.getCoef());

    Region currentRegion = null;

    for(int i = 0; i < regions.size(); i++) {
      Region region = (Region)regions.get(i);
      Rectangle rect = region.getRect();

      if(nordWest) {
        if(Math.abs((int)rect.getX() - xx) < 5
          && Math.abs((int)rect.getY() - yy) < 5)
        {                // Found one.
          currentRegion = region;
          break;
        }
      }
      else {
        if(Math.abs((int)rect.getX() + (int)rect.getWidth() - xx) < 5
          && Math.abs((int)rect.getY() + (int)rect.getHeight() - yy) < 5)
        {                                                    // Found one.
          currentRegion = region;
          break;
        }
      }
    }

    return currentRegion;
  }

  /**
   * Shows popup menu.
   *
   * @param x: Position of menu.
   * @param y: Position of menu.
   */
  private void showPopup(int x, int y)
  {
    selectRegion(x, y);
    repaint();

    // Disable the item if no region is selected.
    deleteSelectedItem.setEnabled(selectedRegion != null);
    popup.show(this, x, y);
  }

        /**
         * Sets the currently selected region in the image panel.
         *
         * @param region:     The region selected.
         */
        private void setSelectedRegion(Region region) {
                selectedRegion = region;
                imagePanel.setSelectedRegion(region);

                if(selectedRegion == null)
                  regionNameField.setText("");
                else
                  regionNameField.setText(selectedRegion.getName());
        }
}
PK
rŽù.ÉkØX$A$A>src/plugins/regionEditorPlugin/RegionEditorPluginTransform.xsl<!-- to-direction for RegionEditor
     status: problems with namespace and comments
     updated to given schema from 15/07/2003 
     Last Revision: 25/07/2003 by Sascha Walkenhorst -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />


<xsl:template match="node()">
        <xsl:if test="not(name() = ('REGIONS'))">
        <xsl:if test="not(name() = ('REGIONSET'))">
        <xsl:if test="not(name() = ('PHOTO'))">
        <xsl:if test="not(name() = ('IMAGE'))">
                <xsl:element name="{name()}">
                        <xsl:for-each select="attribute::*">
                                <xsl:attribute name="{name()}">
                                        <xsl:value-of select="." />
                                </xsl:attribute>
                        </xsl:for-each>

<!--                    
                        <xsl:for-each select="namespace::*">
                                <xsl:attribute name="{name()}">
                                        <xsl:value-of select="." />
                                </xsl:attribute>
                        </xsl:for-each>
-->

                        <xsl:for-each select="node()">
                                <xsl:apply-templates select="." />
                        </xsl:for-each>
                </xsl:element>
        </xsl:if></xsl:if></xsl:if></xsl:if>
</xsl:template>

<xsl:template match="text()">
        <xsl:variable name="testWhetherEmpty">
                <xsl:value-of select="." />
        </xsl:variable>

        <xsl:if test="normalize-space($testWhetherEmpty) != ''">
                <xsl:value-of select="$testWhetherEmpty" />
        </xsl:if>
</xsl:template>

<xsl:template match="REGIONS"><!-- element-plugin association -->
        <xsl:element name="REGIONSET">
                <!-- set extra attribute saving the original name -->
                <xsl:attribute name="XMLEditorSavedNameOfNode">
                        <xsl:value-of select="'REGIONS'" />
                </xsl:attribute>

                <!-- work on attributes -->
                <!-- get information of used image out of attribute 'image' -->
                <xsl:attribute name="image">
                        <xsl:value-of select="@image" />
                </xsl:attribute>
                <!-- copy all other attributes -->
                <xsl:for-each select="attribute::*">
                        <xsl:if test="not(name(.) = 'image')">
                                <xsl:attribute name="{name(.)}">
                                        <xsl:value-of select="self::node()" />
                                </xsl:attribute>
                        </xsl:if>
                </xsl:for-each>

                <!-- work on childs -->
                <!-- get information of used rectangle out of child 'RECTANGLE' -->
                <xsl:for-each select="RECTANGLE">
                        <xsl:element name="RECTANGLE">
                                <!-- copy all attributes -->
                                <xsl:for-each select="attribute::*">
                                        <xsl:attribute name="{name(.)}">
                                                <xsl:value-of select="self::node()" />
                                        </xsl:attribute>
                                </xsl:for-each>
                        
                                <!-- get coordinates -->
                                <xsl:for-each select="COORDS">
                                        <xsl:element name="COORDS">
                                                <xsl:attribute name="x">
                                                        <xsl:value-of select="@x" />
                                                </xsl:attribute>
                                                <xsl:attribute name="y">
                                                        <xsl:value-of select="@y" />
                                                </xsl:attribute>
                                                <xsl:attribute name="w">
                                                        <xsl:value-of select="@w" />
                                                </xsl:attribute>
                                                <xsl:attribute name="h">
                                                        <xsl:value-of select="@h" />
                                                </xsl:attribute>
                                                <xsl:for-each select="attribute::*">
                                                        <xsl:if test="not(name(.) = 'x')">
                                                        <xsl:if test="not(name(.) = 'y')">
                                                        <xsl:if test="not(name(.) = 'w')">
                                                        <xsl:if test="not(name(.) = 'h')">
                                                                <xsl:attribute name="{name(.)}">
                                                                        <xsl:value-of select="self::node()" />
                                                                </xsl:attribute>
                                                        </xsl:if></xsl:if></xsl:if></xsl:if>
                                                </xsl:for-each>
                                                <xsl:for-each select="node()">
                                                        <xsl:apply-templates select="." />
                                                </xsl:for-each>
                                        </xsl:element>
                                </xsl:for-each>
                                <xsl:for-each select="COORD_DATA">
                                        <xsl:element name="COORDS">
                                                <!-- Insert an attribute which saves the original name of node,
                                                     cause all nodes which contain data are transformed to a
                                                     "COORDS" node. This extra information is used in back-
                                                     transformation to restore the original name. -->
                                                <xsl:attribute name="XMLEditorSavedNameOfNode">
                                                        <xsl:value-of select="name(.)" />
                                                </xsl:attribute>

                                                <xsl:attribute name="x">
                                                        <xsl:value-of select="@x_pos" />
                                                </xsl:attribute>
                                                <xsl:attribute name="y">
                                                        <xsl:value-of select="@y_pos" />
                                                </xsl:attribute>
                                                <xsl:attribute name="w">
                                                        <xsl:value-of select="@width" />
                                                </xsl:attribute>
                                                <xsl:attribute name="h">
                                                        <xsl:value-of select="@height" />
                                                </xsl:attribute>
                                                <xsl:for-each select="attribute::*">
                                                        <xsl:if test="not(name(.) = 'x_pos')">
                                                        <xsl:if test="not(name(.) = 'y_pos')">
                                                        <xsl:if test="not(name(.) = 'width')">
                                                        <xsl:if test="not(name(.) = 'height')">
                                                                <xsl:attribute name="{name(.)}">
                                                                        <xsl:value-of select="self::node()" />
                                                                </xsl:attribute>
                                                        </xsl:if></xsl:if></xsl:if></xsl:if>
                                                </xsl:for-each>
                                                <xsl:for-each select="node()">
                                                        <xsl:apply-templates select="." />
                                                </xsl:for-each>
                                        </xsl:element>
                                </xsl:for-each>
                                
                                <!-- copy all other childs -->
                                <xsl:for-each select="node()">
                                        <xsl:if test="not(name(.) = 'COORDS')">
                                        <xsl:if test="not(name(.) = 'COORD_DATA')">
                                                <xsl:apply-templates select="." />
                                        </xsl:if></xsl:if>
                                </xsl:for-each>
                        </xsl:element>
                </xsl:for-each>

                <!-- get information of used ellipse out of child 'ELLIPSE' -->
                <xsl:for-each select="ELLIPSE">
                        <xsl:element name="ELLIPSE">
                                <!-- copy all attributes -->
                                <xsl:for-each select="attribute::*">
                                        <xsl:attribute name="{name(.)}">
                                                <xsl:value-of select="self::node()" />
                                        </xsl:attribute>
                                </xsl:for-each>
                        
                                <!-- get coordinates -->
                                <xsl:for-each select="COORDS">
                                        <xsl:element name="COORDS">
                                                <xsl:attribute name="x">
                                                        <xsl:value-of select="@x" />
                                                </xsl:attribute>
                                                <xsl:attribute name="y">
                                                        <xsl:value-of select="@y" />
                                                </xsl:attribute>
                                                <xsl:attribute name="w">
                                                        <xsl:value-of select="@w" />
                                                </xsl:attribute>
                                                <xsl:attribute name="h">
                                                        <xsl:value-of select="@h" />
                                                </xsl:attribute>
                                                <xsl:attribute name="angle">
                                                        <xsl:value-of select="@angle" />
                                                </xsl:attribute>
                                                <xsl:for-each select="attribute::*">
                                                        <xsl:if test="not(name(.) = 'x')">
                                                        <xsl:if test="not(name(.) = 'y')">
                                                        <xsl:if test="not(name(.) = 'w')">
                                                        <xsl:if test="not(name(.) = 'h')">
                                                        <xsl:if test="not(name(.) = 'angle')">
                                                                <xsl:attribute name="{name(.)}">
                                                                        <xsl:value-of select="self::node()" />
                                                                </xsl:attribute>
                                                        </xsl:if></xsl:if></xsl:if></xsl:if></xsl:if>
                                                </xsl:for-each>
                                                <xsl:for-each select="node()">
                                                        <xsl:apply-templates select="." />
                                                </xsl:for-each>
                                        </xsl:element>
                                </xsl:for-each>
                                
                                <!-- copy all other childs -->
                                <xsl:for-each select="node()">
                                        <xsl:if test="not(name(.) = 'COORDS')">
                                                <xsl:apply-templates select="." />
                                        </xsl:if>
                                </xsl:for-each>
                        </xsl:element>
                </xsl:for-each>

                <!-- get information of used polyline out of child 'POLYLINE' -->
                <xsl:for-each select="POLYLINE">
                        <xsl:element name="POLYLINE">
                                <!-- copy all attributes -->
                                <xsl:for-each select="attribute::*">
                                        <xsl:attribute name="{name(.)}">
                                                <xsl:value-of select="self::node()" />
                                        </xsl:attribute>
                                </xsl:for-each>
                        
                                <!-- get coordinates -->
                                <xsl:for-each select="COORDS">
                                        <xsl:element name="COORDS">
                                                <xsl:attribute name="x">
                                                        <xsl:value-of select="@x" />
                                                </xsl:attribute>
                                                <xsl:attribute name="y">
                                                        <xsl:value-of select="@y" />
                                                </xsl:attribute>
                                                <xsl:for-each select="attribute::*">
                                                        <xsl:if test="not(name(.) = 'x')">
                                                        <xsl:if test="not(name(.) = 'y')">
                                                                <xsl:attribute name="{name(.)}">
                                                                        <xsl:value-of select="self::node()" />
                                                                </xsl:attribute>
                                                        </xsl:if></xsl:if>
                                                </xsl:for-each>
                                                <xsl:for-each select="node()">
                                                        <xsl:apply-templates select="." />
                                                </xsl:for-each>
                                        </xsl:element>
                                </xsl:for-each>
                                
                                <!-- copy all other childs -->
                                <xsl:for-each select="node()">
                                        <xsl:if test="not(name(.) = 'COORDS')">
                                                <xsl:apply-templates select="." />
                                        </xsl:if>
                                </xsl:for-each>
                        </xsl:element>
                </xsl:for-each>

                <!-- copy all other childs -->
                <xsl:for-each select="node()">
                        <xsl:if test="not(name(.) = 'RECTANGLE')">
                        <xsl:if test="not(name(.) = 'ELLIPSE')">
                        <xsl:if test="not(name(.) = 'POLYLINE')">
                                <xsl:apply-templates select="." />
                        </xsl:if></xsl:if></xsl:if>
                </xsl:for-each>

        </xsl:element>
</xsl:template>

<xsl:template match="REGIONSET"><!-- element-plugin association -->
        <xsl:element name="REGIONSET">

                <!-- work on attributes -->
                <!-- get information of used image out of attribute 'image' -->
                <xsl:attribute name="image">
                        <xsl:value-of select="@image" />
                </xsl:attribute>
                <!-- copy all other attributes -->
                <xsl:for-each select="attribute::*">
                        <xsl:if test="not(name(.) = ('image'))">
                                <xsl:attribute name="{name(.)}">
                                        <xsl:value-of select="self::node()" />
                                </xsl:attribute>
                        </xsl:if>
                </xsl:for-each>

                <!-- work on childs -->
                <!-- get information of used rectangle out of child 'RECTANGLE' -->
                <xsl:for-each select="RECTANGLE">
                        <xsl:element name="RECTANGLE">
                                <!-- copy all attributes -->
                                <xsl:for-each select="attribute::*">
                                        <xsl:attribute name="{name(.)}">
                                                <xsl:value-of select="self::node()" />
                                        </xsl:attribute>
                                </xsl:for-each>
                        
                                <!-- get coordinates -->
                                <xsl:for-each select="COORDS">
                                        <xsl:element name="COORDS">
                                                <xsl:attribute name="x">
                                                        <xsl:value-of select="@x" />
                                                </xsl:attribute>
                                                <xsl:attribute name="y">
                                                        <xsl:value-of select="@y" />
                                                </xsl:attribute>
                                                <xsl:attribute name="w">
                                                        <xsl:value-of select="@w" />
                                                </xsl:attribute>
                                                <xsl:attribute name="h">
                                                        <xsl:value-of select="@h" />
                                                </xsl:attribute>
                                                <xsl:for-each select="attribute::*">
                                                        <xsl:if test="not(name(.) = 'x')">
                                                        <xsl:if test="not(name(.) = 'y')">
                                                        <xsl:if test="not(name(.) = 'w')">
                                                        <xsl:if test="not(name(.) = 'h')">
                                                                <xsl:attribute name="{name(.)}">
                                                                        <xsl:value-of select="self::node()" />
                                                                </xsl:attribute>
                                                        </xsl:if></xsl:if></xsl:if></xsl:if>
                                                </xsl:for-each>
                                                <xsl:for-each select="node()">
                                                        <xsl:apply-templates select="." />
                                                </xsl:for-each>
                                        </xsl:element>
                                </xsl:for-each>
                                <xsl:for-each select="COORD_DATA">
                                        <xsl:element name="COORDS">
                                                <!-- Insert an attribute which saves the original name of node,
                                                     cause all nodes which contain data are transformed to a
                                                     "COORDS" node. This extra information is used in back-
                                                     transformation to restore the original name. -->
                                                <xsl:attribute name="XMLEditorSavedNameOfNode">
                                                        <xsl:value-of select="name(.)" />
                                                </xsl:attribute>

                                                <xsl:attribute name="x">
                                                        <xsl:value-of select="@x_pos" />
                                                </xsl:attribute>
                                                <xsl:attribute name="y">
                                                        <xsl:value-of select="@y_pos" />
                                                </xsl:attribute>
                                                <xsl:attribute name="w">
                                                        <xsl:value-of select="@width" />
                                                </xsl:attribute>
                                                <xsl:attribute name="h">
                                                        <xsl:value-of select="@height" />
                                                </xsl:attribute>
                                                <xsl:for-each select="attribute::*">
                                                        <xsl:if test="not(name(.) = 'x_pos')">
                                                        <xsl:if test="not(name(.) = 'y_pos')">
                                                        <xsl:if test="not(name(.) = 'width')">
                                                        <xsl:if test="not(name(.) = 'height')">
                                                                <xsl:attribute name="{name(.)}">
                                                                        <xsl:value-of select="self::node()" />
                                                                </xsl:attribute>
                                                        </xsl:if></xsl:if></xsl:if></xsl:if>
                                                </xsl:for-each>
                                                <xsl:for-each select="node()">
                                                        <xsl:apply-templates select="." />
                                                </xsl:for-each>
                                        </xsl:element>
                                </xsl:for-each>
                                
                                <!-- copy all other childs -->
                                <xsl:for-each select="node()">
                                        <xsl:if test="not(name(.) = 'COORDS')">
                                        <xsl:if test="not(name(.) = 'COORD_DATA')">
                                                <xsl:apply-templates select="." />
                                        </xsl:if></xsl:if>
                                </xsl:for-each>
                        </xsl:element>
                </xsl:for-each>

                <!-- get information of used ellipse out of child 'ELLIPSE' -->
                <xsl:for-each select="ELLIPSE">
                        <xsl:element name="ELLIPSE">
                                <!-- copy all attributes -->
                                <xsl:for-each select="attribute::*">
                                        <xsl:attribute name="{name(.)}">
                                                <xsl:value-of select="self::node()" />
                                        </xsl:attribute>
                                </xsl:for-each>
                        
                                <!-- get coordinates -->
                                <xsl:for-each select="COORDS">
                                        <xsl:element name="COORDS">
                                                <xsl:attribute name="x">
                                                        <xsl:value-of select="@x" />
                                                </xsl:attribute>
                                                <xsl:attribute name="y">
                                                        <xsl:value-of select="@y" />
                                                </xsl:attribute>
                                                <xsl:attribute name="w">
                                                        <xsl:value-of select="@w" />
                                                </xsl:attribute>
                                                <xsl:attribute name="h">
                                                        <xsl:value-of select="@h" />
                                                </xsl:attribute>
                                                <xsl:attribute name="angle">
                                                        <xsl:value-of select="@angle" />
                                                </xsl:attribute>
                                                <xsl:for-each select="attribute::*">
                                                        <xsl:if test="not(name(.) = 'x')">
                                                        <xsl:if test="not(name(.) = 'y')">
                                                        <xsl:if test="not(name(.) = 'w')">
                                                        <xsl:if test="not(name(.) = 'h')">
                                                        <xsl:if test="not(name(.) = 'angle')">
                                                                <xsl:attribute name="{name(.)}">
                                                                        <xsl:value-of select="self::node()" />
                                                                </xsl:attribute>
                                                        </xsl:if></xsl:if></xsl:if></xsl:if></xsl:if>
                                                </xsl:for-each>
                                                <xsl:for-each select="node()">
                                                        <xsl:apply-templates select="." />
                                                </xsl:for-each>
                                        </xsl:element>
                                </xsl:for-each>
                                
                                <!-- copy all other childs -->
                                <xsl:for-each select="node()">
                                        <xsl:if test="not(name(.) = 'COORDS')">
                                                <xsl:apply-templates select="." />
                                        </xsl:if>
                                </xsl:for-each>
                        </xsl:element>
                </xsl:for-each>

                <!-- get information of used polyline out of child 'POLYLINE' -->
                <xsl:for-each select="POLYLINE">
                        <xsl:element name="POLYLINE">
                                <!-- copy all attributes -->
                                <xsl:for-each select="attribute::*">
                                        <xsl:attribute name="{name(.)}">
                                                <xsl:value-of select="self::node()" />
                                        </xsl:attribute>
                                </xsl:for-each>
                        
                                <!-- get coordinates -->
                                <xsl:for-each select="COORDS">
                                        <xsl:element name="COORDS">
                                                <xsl:attribute name="x">
                                                        <xsl:value-of select="@x" />
                                                </xsl:attribute>
                                                <xsl:attribute name="y">
                                                        <xsl:value-of select="@y" />
                                                </xsl:attribute>
                                                <xsl:for-each select="attribute::*">
                                                        <xsl:if test="not(name(.) = 'x')">
                                                        <xsl:if test="not(name(.) = 'y')">
                                                                <xsl:attribute name="{name(.)}">
                                                                        <xsl:value-of select="self::node()" />
                                                                </xsl:attribute>
                                                        </xsl:if></xsl:if>
                                                </xsl:for-each>
                                                <xsl:for-each select="node()">
                                                        <xsl:apply-templates select="." />
                                                </xsl:for-each>
                                        </xsl:element>
                                </xsl:for-each>
                                
                                <!-- copy all other childs -->
                                <xsl:for-each select="node()">
                                        <xsl:if test="not(name(.) = 'COORDS')">
                                                <xsl:apply-templates select="." />
                                        </xsl:if>
                                </xsl:for-each>
                        </xsl:element>
                </xsl:for-each>

                <!-- copy all other childs -->
                <xsl:for-each select="node()">
                        <xsl:if test="not(name(.) = 'RECTANGLE')">
                        <xsl:if test="not(name(.) = 'ELLIPSE')">
                        <xsl:if test="not(name(.) = 'POLYLINE')">
                                <xsl:apply-templates select="." />
                        </xsl:if></xsl:if></xsl:if>
                </xsl:for-each>

        </xsl:element>
</xsl:template>

<xsl:template match="PHOTO">
        <xsl:element name="IMAGE">
                <!-- set extra attribute saving the original name -->
                <xsl:attribute name="XMLEditorSavedNameOfNode">
                        <xsl:value-of select="'PHOTO'" />
                </xsl:attribute>
                
                <!-- work on attributes and childs -->
                <xsl:attribute name="name">
                        <xsl:value-of select="@label" />
                </xsl:attribute>
                <xsl:attribute name="url">
                        <xsl:value-of select="@uri" />
                </xsl:attribute>
                <xsl:for-each select="attribute::*">
                        <xsl:if test="not(name(.) = ('label'))">
                        <xsl:if test="not(name(.) = ('uri'))">
                                <xsl:attribute name="{name(.)}">
                                        <xsl:value-of select="self::node()" />
                                </xsl:attribute>
                        </xsl:if></xsl:if>
                </xsl:for-each>
                <xsl:for-each select="node()">
                        <xsl:apply-templates select="." />
                </xsl:for-each>
        </xsl:element>
</xsl:template>

<xsl:template match="IMAGE">
        <xsl:element name="IMAGE">
                <!-- work on attributes and childs -->
                <xsl:attribute name="name">
                        <xsl:value-of select="@label" />
                </xsl:attribute>
                <xsl:attribute name="url">
                        <xsl:value-of select="@uri" />
                </xsl:attribute>
                <xsl:for-each select="attribute::*">
                        <xsl:if test="not(name(.) = ('label'))">
                        <xsl:if test="not(name(.) = ('uri'))">
                                <xsl:attribute name="{name(.)}">
                                        <xsl:value-of select="self::node()" />
                                </xsl:attribute>
                        </xsl:if></xsl:if>
                </xsl:for-each>
                <xsl:for-each select="node()">
                        <xsl:apply-templates select="." />
                </xsl:for-each>
        </xsl:element>
</xsl:template>


</xsl:stylesheet>PK
ðhù.î}ñDñDBsrc/plugins/regionEditorPlugin/RegionEditorPluginTransformBack.xsl<!-- back-direction for RegionEditor
     status: problems with namespace and comments
     updated to given schema from 15/07/2003 
     Last Revision: 25/07/2003 by Sascha Walkenhorst -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />


<xsl:template match="node()">
        <xsl:if test="not(name() = ('REGIONSET'))">
        <xsl:if test="not(name() = ('IMAGE'))">
                <xsl:element name="{name()}">
                        <xsl:for-each select="attribute::*">
                                <xsl:attribute name="{name()}">
                                        <xsl:value-of select="." />
                                </xsl:attribute>
                        </xsl:for-each>
                
                        <xsl:for-each select="node()">
                                <xsl:apply-templates select="." />
                        </xsl:for-each>
                </xsl:element>
        </xsl:if></xsl:if>
</xsl:template>

<xsl:template match="text()">
        <xsl:variable name="testWhetherEmpty">
                <xsl:value-of select="." />
        </xsl:variable>

        <xsl:if test="normalize-space($testWhetherEmpty) != ''">
                <xsl:value-of select="$testWhetherEmpty" />
        </xsl:if>
</xsl:template>


<xsl:template match="REGIONSET">
        <xsl:choose>
                <xsl:when test="@XMLEditorSavedNameOfNode = 'REGIONS'">
                        <xsl:element name="REGIONS">
                
                                <!-- work on attributes -->
                                <!-- get information of used image out of attribute 'image' -->
                                <xsl:attribute name="image">
                                        <xsl:value-of select="@image" />
                                </xsl:attribute>
                                <!-- copy all other attributes -->
                                <xsl:for-each select="attribute::*">
                                        <xsl:if test="not(name(.) = 'image')">
                                        <xsl:if test="not(name(.) = 'XMLEditorSavedNameOfNode')">
                                                <xsl:attribute name="{name(.)}">
                                                        <xsl:value-of select="self::node()" />
                                                </xsl:attribute>
                                        </xsl:if></xsl:if>
                                </xsl:for-each>
                
                                <!-- work on childs -->
                                <!-- get information of used rectangle out of child 'RECTANGLE' -->
                                <xsl:for-each select="RECTANGLE">
                                        <xsl:element name="RECTANGLE">
                                                <!-- copy all attributes -->
                                                <xsl:for-each select="attribute::*">
                                                        <xsl:attribute name="{name(.)}">
                                                                <xsl:value-of select="self::node()" />
                                                        </xsl:attribute>
                                                </xsl:for-each>
                        
                                                <!-- get coordinates -->
                                                <!-- during transformation in to-direction an attribute named 
                                                     "XMLEditorSavedNameOfNode" should have been created which
                                                     contains the name of the element the original element had
                                                     if its name was not COORDS which is the standard name. With
                                                     this information can the original element reconstructed.-->
                                                <xsl:for-each select="COORDS">
                                                        <xsl:choose>
                                                                <xsl:when test="@XMLEditorSavedNameOfNode = 'COORD_DATA'">
                                                                        <xsl:element name="COORD_DATA">
                                                                                <xsl:attribute name="x_pos">
                                                                                        <xsl:value-of select="@x" />
                                                                                </xsl:attribute>
                                                                                <xsl:attribute name="y_pos">
                                                                                        <xsl:value-of select="@y" />
                                                                                </xsl:attribute>
                                                                                <xsl:attribute name="width">
                                                                                        <xsl:value-of select="@w" />
                                                                                </xsl:attribute>
                                                                                <xsl:attribute name="height">
                                                                                        <xsl:value-of select="@h" />
                                                                                </xsl:attribute>
                                                                                <xsl:for-each select="attribute::*">
                                                                                        <xsl:if test="not(name(.) = 'x')">
                                                                                        <xsl:if test="not(name(.) = 'y')">
                                                                                        <xsl:if test="not(name(.) = 'w')">
                                                                                        <xsl:if test="not(name(.) = 'h')">
                                                                                        <xsl:if test="not(name(.) = 'XMLEditorSavedNameOfNode')">
                                                                                                <xsl:attribute name="{name(.)}">
                                                                                                        <xsl:value-of select="self::node()" />
                                                                                                </xsl:attribute>
                                                                                        </xsl:if></xsl:if></xsl:if></xsl:if></xsl:if>
                                                                                </xsl:for-each>
                                                                                <xsl:for-each select="node()">
                                                                                        <xsl:apply-templates select="." />
                                                                                </xsl:for-each>
                                                                        </xsl:element>
                                                                </xsl:when>
                                                                <xsl:otherwise>
                                                                        <xsl:element name="COORDS">
                                                                                <xsl:attribute name="x">
                                                                                        <xsl:value-of select="@x" />
                                                                                </xsl:attribute>
                                                                                <xsl:attribute name="y">
                                                                                        <xsl:value-of select="@y" />
                                                                                </xsl:attribute>
                                                                                <xsl:attribute name="w">
                                                                                        <xsl:value-of select="@w" />
                                                                                </xsl:attribute>
                                                                                <xsl:attribute name="h">
                                                                                        <xsl:value-of select="@h" />
                                                                                </xsl:attribute>
                                                                                <xsl:for-each select="attribute::*">
                                                                                        <xsl:if test="not(name(.) = 'x')">
                                                                                        <xsl:if test="not(name(.) = 'y')">
                                                                                        <xsl:if test="not(name(.) = 'w')">
                                                                                        <xsl:if test="not(name(.) = 'h')">
                                                                                                <xsl:attribute name="{name(.)}">
                                                                                                        <xsl:value-of select="self::node()" />
                                                                                                </xsl:attribute>
                                                                                        </xsl:if></xsl:if></xsl:if></xsl:if>
                                                                                </xsl:for-each>
                                                                                <xsl:for-each select="node()">
                                                                                        <xsl:apply-templates select="." />
                                                                                </xsl:for-each>
                                                                        </xsl:element>
                                                                </xsl:otherwise>
                                                        </xsl:choose>
                                                </xsl:for-each>
                
                                                <!-- copy all other childs -->
                                                <xsl:for-each select="node()">
                                                        <xsl:if test="not(name(.) = 'COORDS')">
                                                                <xsl:apply-templates select="." />
                                                        </xsl:if>
                                                </xsl:for-each>
                                        </xsl:element>
                                </xsl:for-each>
                
                                <!-- get information of used ellipse out of child 'ELLIPSE' -->
                                <xsl:for-each select="ELLIPSE">
                                        <xsl:element name="ELLIPSE">
                                                <!-- copy all attributes -->
                                                <xsl:for-each select="attribute::*">
                                                        <xsl:attribute name="{name(.)}">
                                                                <xsl:value-of select="self::node()" />
                                                        </xsl:attribute>
                                                </xsl:for-each>
                        
                                                <!-- get coordinates -->
                                                <xsl:for-each select="COORDS">
                                                        <xsl:element name="COORDS">
                                                                <xsl:attribute name="x">
                                                                        <xsl:value-of select="@x" />
                                                                </xsl:attribute>
                                                                <xsl:attribute name="y">
                                                                        <xsl:value-of select="@y" />
                                                                </xsl:attribute>
                                                                <xsl:attribute name="w">
                                                                        <xsl:value-of select="@w" />
                                                                </xsl:attribute>
                                                                <xsl:attribute name="h">
                                                                        <xsl:value-of select="@h" />
                                                                </xsl:attribute>
                                                                <xsl:attribute name="angle">
                                                                        <xsl:value-of select="@angle" />
                                                                </xsl:attribute>
                                                                <xsl:for-each select="attribute::*">
                                                                        <xsl:if test="not(name(.) = 'x')">
                                                                        <xsl:if test="not(name(.) = 'y')">
                                                                        <xsl:if test="not(name(.) = 'w')">
                                                                        <xsl:if test="not(name(.) = 'h')">
                                                                        <xsl:if test="not(name(.) = 'angle')">
                                                                                <xsl:attribute name="{name(.)}">
                                                                                        <xsl:value-of select="self::node()" />
                                                                                </xsl:attribute>
                                                                        </xsl:if></xsl:if></xsl:if></xsl:if></xsl:if>
                                                                </xsl:for-each>
                                                                <xsl:for-each select="node()">
                                                                        <xsl:apply-templates select="." />
                                                                </xsl:for-each>
                                                        </xsl:element>
                                                </xsl:for-each>
                                                <!-- copy all other childs -->
                                                <xsl:for-each select="node()">
                                                        <xsl:if test="not(name(.) = 'COORDS')">
                                                                <xsl:apply-templates select="." />
                                                        </xsl:if>
                                                </xsl:for-each>
                                        </xsl:element>
                                </xsl:for-each>
                
                                <!-- get information of used polyline out of child 'POLYLINE' -->
                                <xsl:for-each select="POLYLINE">
                                        <xsl:element name="POLYLINE">
                                                <!-- copy all attributes -->
                                                <xsl:for-each select="attribute::*">
                                                        <xsl:attribute name="{name(.)}">
                                                                <xsl:value-of select="self::node()" />
                                                        </xsl:attribute>
                                                </xsl:for-each>
                        
                                                <!-- get coordinates -->
                                                <xsl:for-each select="COORDS">
                                                        <xsl:element name="COORDS">
                                                                <xsl:attribute name="x">
                                                                        <xsl:value-of select="@x" />
                                                                </xsl:attribute>
                                                                <xsl:attribute name="y">
                                                                        <xsl:value-of select="@y" />
                                                                </xsl:attribute>
                                                                <xsl:for-each select="attribute::*">
                                                                        <xsl:if test="not(name(.) = 'x')">
                                                                        <xsl:if test="not(name(.) = 'y')">
                                                                                <xsl:attribute name="{name(.)}">
                                                                                        <xsl:value-of select="self::node()" />
                                                                                </xsl:attribute>
                                                                        </xsl:if></xsl:if>
                                                                </xsl:for-each>
                                                                <xsl:for-each select="node()">
                                                                        <xsl:apply-templates select="." />
                                                                </xsl:for-each>
                                                        </xsl:element>
                                                </xsl:for-each>
                                                <!-- copy all other childs -->
                                                <xsl:for-each select="node()">
                                                        <xsl:if test="not(name(.) = 'COORDS')">
                                                                <xsl:apply-templates select="." />
                                                        </xsl:if>
                                                </xsl:for-each>
                                        </xsl:element>
                                </xsl:for-each>
                
                                <!-- copy all other childs -->
                                <xsl:for-each select="node()">
                                        <xsl:if test="not(name(.) = 'RECTANGLE')">
                                        <xsl:if test="not(name(.) = 'ELLIPSE')">
                                        <xsl:if test="not(name(.) = 'POLYLINE')">
                                                <xsl:apply-templates select="." />
                                        </xsl:if></xsl:if></xsl:if>
                                </xsl:for-each>
                
                        </xsl:element>
                </xsl:when>
                
                <xsl:otherwise>
                        <xsl:element name="REGIONSET">
                
                                <!-- work on attributes -->
                                <!-- get information of used image out of attribute 'image' -->
                                <xsl:attribute name="image">
                                        <xsl:value-of select="@image" />
                                </xsl:attribute>
                                <!-- copy all other attributes -->
                                <xsl:for-each select="attribute::*">
                                        <xsl:if test="not(name(.) = 'image')">
                                        <xsl:if test="not(name(.) = 'XMLEditorSavedNameOfNode')">
                                                <xsl:attribute name="{name(.)}">
                                                        <xsl:value-of select="self::node()" />
                                                </xsl:attribute>
                                        </xsl:if></xsl:if>
                                </xsl:for-each>
                
                                <!-- work on childs -->
                                <!-- get information of used rectangle out of child 'RECTANGLE' -->
                                <xsl:for-each select="RECTANGLE">
                                        <xsl:element name="RECTANGLE">
                                                <!-- copy all attributes -->
                                                <xsl:for-each select="attribute::*">
                                                        <xsl:attribute name="{name(.)}">
                                                                <xsl:value-of select="self::node()" />
                                                        </xsl:attribute>
                                                </xsl:for-each>
                        
                                                <!-- get coordinates -->
                                                <!-- during transformation in to-direction an attribute named 
                                                     "XMLEditorSavedNameOfNode" should have been created which
                                                     contains the name of the element the original element had
                                                     if its name was not COORDS which is the standard name. With
                                                     this information can the original element reconstructed.-->
                                                <xsl:for-each select="COORDS">
                                                        <xsl:choose>
                                                                <xsl:when test="@XMLEditorSavedNameOfNode = 'COORD_DATA'">
                                                                        <xsl:element name="COORD_DATA">
                                                                                <xsl:attribute name="x_pos">
                                                                                        <xsl:value-of select="@x" />
                                                                                </xsl:attribute>
                                                                                <xsl:attribute name="y_pos">
                                                                                        <xsl:value-of select="@y" />
                                                                                </xsl:attribute>
                                                                                <xsl:attribute name="width">
                                                                                        <xsl:value-of select="@w" />
                                                                                </xsl:attribute>
                                                                                <xsl:attribute name="height">
                                                                                        <xsl:value-of select="@h" />
                                                                                </xsl:attribute>
                                                                                <xsl:for-each select="attribute::*">
                                                                                        <xsl:if test="not(name(.) = 'x')">
                                                                                        <xsl:if test="not(name(.) = 'y')">
                                                                                        <xsl:if test="not(name(.) = 'w')">
                                                                                        <xsl:if test="not(name(.) = 'h')">
                                                                                        <xsl:if test="not(name(.) = 'XMLEditorSavedNameOfNode')">
                                                                                                <xsl:attribute name="{name(.)}">
                                                                                                        <xsl:value-of select="self::node()" />
                                                                                                </xsl:attribute>
                                                                                        </xsl:if></xsl:if></xsl:if></xsl:if></xsl:if>
                                                                                </xsl:for-each>
                                                                                <xsl:for-each select="node()">
                                                                                        <xsl:apply-templates select="." />
                                                                                </xsl:for-each>
                                                                        </xsl:element>
                                                                </xsl:when>
                                                                <xsl:otherwise>
                                                                        <xsl:element name="COORDS">
                                                                                <xsl:attribute name="x">
                                                                                        <xsl:value-of select="@x" />
                                                                                </xsl:attribute>
                                                                                <xsl:attribute name="y">
                                                                                        <xsl:value-of select="@y" />
                                                                                </xsl:attribute>
                                                                                <xsl:attribute name="w">
                                                                                        <xsl:value-of select="@w" />
                                                                                </xsl:attribute>
                                                                                <xsl:attribute name="h">
                                                                                        <xsl:value-of select="@h" />
                                                                                </xsl:attribute>
                                                                                <xsl:for-each select="attribute::*">
                                                                                        <xsl:if test="not(name(.) = 'x')">
                                                                                        <xsl:if test="not(name(.) = 'y')">
                                                                                        <xsl:if test="not(name(.) = 'w')">
                                                                                        <xsl:if test="not(name(.) = 'h')">
                                                                                                <xsl:attribute name="{name(.)}">
                                                                                                        <xsl:value-of select="self::node()" />
                                                                                                </xsl:attribute>
                                                                                        </xsl:if></xsl:if></xsl:if></xsl:if>
                                                                                </xsl:for-each>
                                                                                <xsl:for-each select="node()">
                                                                                        <xsl:apply-templates select="." />
                                                                                </xsl:for-each>
                                                                        </xsl:element>
                                                                </xsl:otherwise>
                                                        </xsl:choose>
                                                </xsl:for-each>
                
                                                <!-- copy all other childs -->
                                                <xsl:for-each select="node()">
                                                        <xsl:if test="not(name(.) = 'COORDS')">
                                                                <xsl:apply-templates select="." />
                                                        </xsl:if>
                                                </xsl:for-each>
                                        </xsl:element>
                                </xsl:for-each>
                
                                <!-- get information of used ellipse out of child 'ELLIPSE' -->
                                <xsl:for-each select="ELLIPSE">
                                        <xsl:element name="ELLIPSE">
                                                <!-- copy all attributes -->
                                                <xsl:for-each select="attribute::*">
                                                        <xsl:attribute name="{name(.)}">
                                                                <xsl:value-of select="self::node()" />
                                                        </xsl:attribute>
                                                </xsl:for-each>
                        
                                                <!-- get coordinates -->
                                                <xsl:for-each select="COORDS">
                                                        <xsl:element name="COORDS">
                                                                <xsl:attribute name="x">
                                                                        <xsl:value-of select="@x" />
                                                                </xsl:attribute>
                                                                <xsl:attribute name="y">
                                                                        <xsl:value-of select="@y" />
                                                                </xsl:attribute>
                                                                <xsl:attribute name="w">
                                                                        <xsl:value-of select="@w" />
                                                                </xsl:attribute>
                                                                <xsl:attribute name="h">
                                                                        <xsl:value-of select="@h" />
                                                                </xsl:attribute>
                                                                <xsl:attribute name="angle">
                                                                        <xsl:value-of select="@angle" />
                                                                </xsl:attribute>
                                                                <xsl:for-each select="attribute::*">
                                                                        <xsl:if test="not(name(.) = 'x')">
                                                                        <xsl:if test="not(name(.) = 'y')">
                                                                        <xsl:if test="not(name(.) = 'w')">
                                                                        <xsl:if test="not(name(.) = 'h')">
                                                                        <xsl:if test="not(name(.) = 'angle')">
                                                                                <xsl:attribute name="{name(.)}">
                                                                                        <xsl:value-of select="self::node()" />
                                                                                </xsl:attribute>
                                                                        </xsl:if></xsl:if></xsl:if></xsl:if></xsl:if>
                                                                </xsl:for-each>
                                                                <xsl:for-each select="node()">
                                                                        <xsl:apply-templates select="." />
                                                                </xsl:for-each>
                                                        </xsl:element>
                                                </xsl:for-each>
                                                <!-- copy all other childs -->
                                                <xsl:for-each select="node()">
                                                        <xsl:if test="not(name(.) = 'COORDS')">
                                                                <xsl:apply-templates select="." />
                                                        </xsl:if>
                                                </xsl:for-each>
                                        </xsl:element>
                                </xsl:for-each>
                
                                <!-- get information of used polyline out of child 'POLYLINE' -->
                                <xsl:for-each select="POLYLINE">
                                        <xsl:element name="POLYLINE">
                                                <!-- copy all attributes -->
                                                <xsl:for-each select="attribute::*">
                                                        <xsl:attribute name="{name(.)}">
                                                                <xsl:value-of select="self::node()" />
                                                        </xsl:attribute>
                                                </xsl:for-each>
                        
                                                <!-- get coordinates -->
                                                <xsl:for-each select="COORDS">
                                                        <xsl:element name="COORDS">
                                                                <xsl:attribute name="x">
                                                                        <xsl:value-of select="@x" />
                                                                </xsl:attribute>
                                                                <xsl:attribute name="y">
                                                                        <xsl:value-of select="@y" />
                                                                </xsl:attribute>
                                                                <xsl:for-each select="attribute::*">
                                                                        <xsl:if test="not(name(.) = 'x')">
                                                                        <xsl:if test="not(name(.) = 'y')">
                                                                                <xsl:attribute name="{name(.)}">
                                                                                        <xsl:value-of select="self::node()" />
                                                                                </xsl:attribute>
                                                                        </xsl:if></xsl:if>
                                                                </xsl:for-each>
                                                                <xsl:for-each select="node()">
                                                                        <xsl:apply-templates select="." />
                                                                </xsl:for-each>
                                                        </xsl:element>
                                                </xsl:for-each>
                                                <!-- copy all other childs -->
                                                <xsl:for-each select="node()">
                                                        <xsl:if test="not(name(.) = 'COORDS')">
                                                                <xsl:apply-templates select="." />
                                                        </xsl:if>
                                                </xsl:for-each>
                                        </xsl:element>
                                </xsl:for-each>
                
                                <!-- copy all other childs -->
                                <xsl:for-each select="node()">
                                        <xsl:if test="not(name(.) = 'RECTANGLE')">
                                        <xsl:if test="not(name(.) = 'ELLIPSE')">
                                        <xsl:if test="not(name(.) = 'POLYLINE')">
                                                <xsl:apply-templates select="." />
                                        </xsl:if></xsl:if></xsl:if>
                                </xsl:for-each>
                
                        </xsl:element>

                </xsl:otherwise>
        </xsl:choose>
</xsl:template>

<xsl:template match="IMAGE">
        <xsl:choose>
                <xsl:when test="@XMLEditorSavedNameOfNode = 'PHOTO'">
                        <xsl:element name="PHOTO">
                                <!-- work on attributes and childs -->
                                <xsl:attribute name="label">
                                        <xsl:value-of select="@name" />
                                </xsl:attribute>
                                <xsl:attribute name="uri">
                                        <xsl:value-of select="@url" />
                                </xsl:attribute>
                                <xsl:for-each select="attribute::*">
                                        <xsl:if test="not(name(.) = ('name'))">
                                        <xsl:if test="not(name(.) = ('url'))">
                                        <xsl:if test="not(name(.) = ('XMLEditorSavedNameOfNode'))">
                                                <xsl:attribute name="{name(.)}">
                                                        <xsl:value-of select="self::node()" />
                                                </xsl:attribute>
                                        </xsl:if></xsl:if></xsl:if>
                                </xsl:for-each>
                                <xsl:for-each select="node()">
                                        <xsl:apply-templates select="." />
                                </xsl:for-each>
                        </xsl:element>
                </xsl:when>
                
                <xsl:otherwise>
                        <xsl:element name="IMAGE">
                                <!-- work on attributes and childs -->
                                <xsl:attribute name="label">
                                        <xsl:value-of select="@name" />
                                </xsl:attribute>
                                <xsl:attribute name="uri">
                                        <xsl:value-of select="@url" />
                                </xsl:attribute>
                                <xsl:for-each select="attribute::*">
                                        <xsl:if test="not(name(.) = ('name'))">
                                        <xsl:if test="not(name(.) = ('url'))">
                                                <xsl:attribute name="{name(.)}">
                                                        <xsl:value-of select="self::node()" />
                                                </xsl:attribute>
                                        </xsl:if></xsl:if>
                                </xsl:for-each>
                                <xsl:for-each select="node()">
                                        <xsl:apply-templates select="." />
                                </xsl:for-each>
                        </xsl:element>
                </xsl:otherwise>
        </xsl:choose>
</xsl:template>


</xsl:stylesheet>PK

wŽù. META-INF/þÊPK

wŽù.(\<MM+META-INF/MANIFEST.MFPK

A‰ù.ÓÆ`ö»»/ªsrc/plugins/regionEditorPlugin/ImagePanel.classPK

U|ø.ñù8XÇÇ.²src/plugins/regionEditorPlugin/ImagePanel.javaPK

A‰ù.154_™™+Å"src/plugins/regionEditorPlugin/Region.classPK

Cù..©Ñ××*§'src/plugins/regionEditorPlugin/Region.javaPK

çù.[èÿ\A\A7Æ/src/plugins/regionEditorPlugin/RegionEditorPlugin.classPK

çù.¯óÝù?a?a6wqsrc/plugins/regionEditorPlugin/RegionEditorPlugin.javaPK

rŽù.ÉkØX$A$A>
Ósrc/plugins/regionEditorPlugin/RegionEditorPluginTransform.xslPK

ðhù.î}ñDñDBŠsrc/plugins/regionEditorPlugin/RegionEditorPluginTransformBack.xslPK

ŒÛY