Subversion Repositories general

Rev

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

PK

}÷.        META-INF/þÊPK

}÷.ñÍSºMMMETA-INF/MANIFEST.MFManifest-Version: 1.0
Comment: you can set named regions on pictures
Transform-To-File: src/plugins/regionEditorPlugin/RegionEditorPluginTr
 ansform.xsl
Created-By: 1.4.0 (Sun Microsystems Inc.)
Description: ...(todo)
XMLEditor-Plugin-Name: RegionEditor
Class-Path: ImagePlugin.jar
Transform-Fro-File: src/plugins/regionEditorPlugin/RegionEditorPluginT
 ransformBack.xsl
Main-Class: src.plugins.regionEditorPlugin.RegionEditorPlugin

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

PK
{÷.‘ƒÖ»»/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
Do÷.ÆL7Œ.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.4 $
 *
 * Last modification: $Date: 2003/07/23 11:58:09 $
 * $Id: ImagePanel.java,v 1.4 2003/07/23 11:58:09 ioklasse 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
 * @author Viktoriya Zudova
 *
 * @version $Revision: 1.4 $ Last modification: $Date: 2003/07/23 11:58:09 $
 */
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 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();
        }

        // TODO comments
        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;
        }

        // TODO comments
        public void setSelectedRegion(Region region) {
                this.selectedRegion = region;
        }
}PK
{÷.h®‘¡ÂÂ+src/plugins/regionEditorPlugin/Region.classÊþº¾-!%src/plugins/regionEditorPlugin/Regionjava/lang/ObjectnameLjava/lang/String;rectLjava/awt/Rectangle;<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;)V
SourceFileRegion.java! 
3*·
±
 " Y*·
*+µ*,µ±%'      () /*´°.>*+µ±
45/*´°:>*+µ±
@A PK
Do÷.·`΂ÉÉ*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.2 $
 *
 * Last modification: $Date: 2003/07/23 11:58:09 $
 * $Id: Region.java,v 1.2 2003/07/23 11:58:09 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;

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

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

  /* returns the name of the region */
  public String getName()
  {
        return name;
  }

  /* sets the name of the region */
  public void setName(String name)
  {
        this.name = name;
  }

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

  /* sets the coordinates of the region */
  public void setRect(Rectangle rect)
  {
        this.rect = rect;
  }
}
PK
{÷.ŸÙæKI;I;7src/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;imageNameFieldLjavax/swing/JTextField;
confirmButtonLjavax/swing/JButton;regionNameFieldregionConfirmButton
imagePanel+Lsrc/plugins/regionEditorPlugin/ImagePanel;guiLsrc/gui/GuiInterface;ourEventListenerLsrc/control/OurEventListener;   imageNameimageUrlcurrentFileLjava/io/File;oldNodeLorg/w3c/dom/Node;changedNoderegionsLjava/util/List;selectedRegion'Lsrc/plugins/regionEditorPlugin/Region;normalCursorLjava/awt/Cursor;
moveCursorresizeCursorinMoveZinResizepopupLjavax/swing/JPopupMenu;deleteSelectedItemLjavax/swing/JMenuItem;<init>()VCode67
9
       ;javax/swing/JTextField=
>9       @javax/swing/JButtonBConfirmD(Ljava/lang/String;)V6F
CG       I       K       Mjava/util/ArrayListO
P9'(       Rjava/awt/CursorT(I)V6V
UW+,       Y-,       [.,       ]/0       _10       ajavax/swing/JPopupMenuc
d923       fjavax/swing/JMenuItemhDelete the regionj
iG45       mjava/awt/BorderLayouto
p9java/awt/Containerr  setLayout(Ljava/awt/LayoutManager;)Vtu
sv)src/plugins/regionEditorPlugin/ImagePanelx(Ljava/util/List;)V6z
y{       }java/awt/ComponentaddMouseListener!(Ljava/awt/event/MouseListener;)V‚
€ƒaddMouseMotionListener'(Ljava/awt/event/MouseMotionListener;)V…†
€‡add*(Ljava/awt/Component;)Ljava/awt/Component;‰Š
s‹East)(Ljava/awt/Component;Ljava/lang/Object;)V‰
sjava/awt/Dimension’(II)V6”
“•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;‰¥
d¦
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ÄVÃÅ
setMessageÇFÃÈsetPoint(Ljava/awt/Point;)VÊËÃÌ        printTree(Lorg/w3c/dom/Node;I)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/tree/TreePathç
getParentPath()Ljavax/swing/tree/TreePath;éê
èëgetLastPathComponent()Ljava/lang/Object;íî
èïsrc/parser/AdapterNodeñgetUrlForLabel>(Ljava/lang/String;Lsrc/parser/AdapterNode;)Ljava/lang/String;óô
õgetLogInterface()Lsrc/gui/LogInterface;÷ø½ùjava/lang/StringBufferû Picture "ý
üGappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;
ü" not found in document.toStringà
ü    src/gui/LogInterfacelog(ILjava/lang/String;)V
javax/swing/text/JTextComponentsetTextF
  loadImageF
initRegions(Lorg/w3c/dom/Node;)V
setPluginPanel(Ljavax/swing/JPanel;)V½nodeenvironmentLorg/w3c/dom/Document;elementPathLjavax/swing/tree/TreePath;workingPathparentLsrc/parser/AdapterNode;getChild(I)Lsrc/parser/AdapterNode;)*
ò+ toDomNode()Lorg/w3c/dom/Node;-.
ò/
hasAttributes()Z12Ó3item(I)Lorg/w3c/dom/Node;56Ú7java/lang/String9equals(Ljava/lang/Object;)Z;<
:=toLowerCase?à
:@.jpgBendsWith(Ljava/lang/String;)ZDE
:F.gifH.pngJ      getLength()ILMÚN6
òP
childCountRM
òSlabelresulttemp
attribTempnodeListLorg/w3c/dom/NamedNodeMap;exitiIjk     attributejava/util/Listaclearc7bd
getChildNodes()Lorg/w3c/dom/NodeList;fgÓhorg/w3c/dom/NodeListjk7getNodeNamemàÓn        RECTANGLEpCOORDSrxtjava/lang/IntegervparseInt(Ljava/lang/String;)Ixy
wzy|w~h€#text‚trim„à
:…‡kN%src/plugins/regionEditorPlugin/RegionŠjava/awt/RectangleŒ(IIII)V6Ž
)(Ljava/lang/String;Ljava/awt/Rectangle;)V6‘
‹’‰<b”java/lang/NumberFormatException–childrenLorg/w3c/dom/NodeList;rectNoderectChildrennamesubnodeattrsex!Ljava/lang/NumberFormatException;valuejava/lang/System¢outLjava/io/PrintStream;¤¥       £¦1=================================================¨java/io/PrintStreamªprintln¬F
«­ ¯print±F
«²valueOf&(Ljava/lang/Object;)Ljava/lang/String;´µ
:¶:¸="º [¼]¾¬7
«ÀindentliststopsetOurEventListener!(Lsrc/control/OurEventListener;)V    ÇnewListenerforceStatusReport       cloneNode(Z)Lorg/w3c/dom/Node;ËÌÓÍ&%    ÏsetNodeValueÑFÓÒfirePluginChangedElement'(Lorg/w3c/dom/Node;Lorg/w3c/dom/Node;)VÔÕ
Ösrc/control/OurEventØjava/lang/ObjectÚ([Ljava/lang/Object;)V6Ü
ÙÝsrc/control/OurEventListenerß
firedOurEvent(Lsrc/control/OurEvent;)VáâàãeLsrc/control/OurEvent;sendRegionChanged*(Lsrc/plugins/regionEditorPlugin/Region;)Vregion"# ê      ìNo imageîgetCurrentFile()Ljava/io/File;ðñ½òjava/io/Fileô
getParentFileöñ
õ÷
õ    
startsWithúE
:û/ýreplaceFirst8(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;ÿ
:charAt(I)C
:
õG#(Ljava/io/File;Ljava/lang/String;)V6
õ    javax/imageio/ImageIOread.(Ljava/io/File;)Ljava/awt/image/BufferedImage;

Show image from Cannot open file setImage(Ljava/awt/Image;)V
yjava/io/IOExceptionfileNamedocLjava/io/IOException;actionPerformed(Ljava/awt/event/ActionEvent;)Vjava/util/EventObject  getSource"î
!#getText%à
&Ê7
()*       *setName,F
‹-çè
/deleteRegion1è
2Ljava/awt/event/ActionEvent;mouseDragged(Ljava/awt/event/MouseEvent;)Vjava/awt/event/MouseEvent7getX9M
8:getY<M
8=  showMouse?”
@getRect()Ljava/awt/Rectangle;BC
‹DgetDxFM
yGgetCoef()DIJ
yKgetDyMM
yNgetWidthPJ
Qjava/awt/ImageS!(Ljava/awt/image/ImageObserver;)IPU
TV  getHeightXJ
YXU
T[setLocation]”
^repaint`7
€a9J
c<J
esetSizeg”
hsetSelectedRegionjè
k  addRegionmè
nLjava/awt/event/MouseEvent;rectLjava/awt/Rectangle;D
mouseMoved
findRegion,(IIZ)Lsrc/plugins/regionEditorPlugin/Region;uv
w  setCursor(Ljava/awt/Cursor;)Vyz
€{region1region2
getImageWidthM
y€getImageHeight‚M
yƒjava/awt/Point…
†•mouseXmouseYxxyymouseClickedselectRegion”
ŽmousePressedisPopupTrigger‘2
8’        showPopup””
•
mouseReleasedmouseEnteredmouseExitedremoveš<b›get(I)Ljava/lang/Object;žbŸcontains(II)Z¡¢
£size¥Mb¦java/lang/Math¨abs(I)Iª«
©¬nordWest
currentRegion
setEnabled°©
i±show(Ljava/awt/Component;II)V³´
dµ
ykgetName¸à
‹¹
SourceFileRegionEditorPlugin.java!

 !"#$%&%'()*+,-,.,/0102345678Ll*·:*µ<*»>Y·?µA*»CYE·HµJ*»>Y·?µL*»CYE·HµN*»PY·QµS*»UY·XµZ*»UY
·Xµ\*»UY·Xµ^*µ`*µb*»dY·eµg*»iYk·lµn*»pY·q¶w*»yY*´S·|µ~*´~*¶„*´~*¶ˆ»Y·:L+»pY·q¶w+*´A¶ŒW+*´JŽ¶‘»Y·:M,»“Yð·–¶œ,»pY·q¶w,*´L¶ŒW,*´NŽ¶‘»Y·:N-»pY·q¶w-+¶ŒW-,Ž¶‘*-ž¶‘**´~¶ŒW*´J*¶¤*´N*¶¤*´n*¶¤*´g*´n¶§W*¶«±¬ž'ŠE
KN"Q-T:oEuQx^{j~ot„‡Œ—¦‘®’¶•¾–ɗҘܛäœôÿžŸ¢£%¤+¥2§9¨BªJ«R®Z¯f±k²­*l®¯¾®°±䈲±R³±´µ8>*+µ·±¬
º»­®¯¸¹8”è*+µ»*´·¹Á¹Æ*´·¹Á¹É*´·¹Á¹Í*+·Ñ+Æ*+¹×عÞ¹âµä*µæ-¶ìY::¶ðÀò:***´ä·öµæ¶ì:*´æÇÇÿØ*´æÇ1*´·¹ú»üYþ·ÿ*´ä¶¶¶¶
¹*´A*´ä¶**´æ·*+·*´·*¹ *¶«±¬VÉÊË#Ì2Î8Ï<ÐRÓWÔ`ØjÙxÚÝ‹à’áÀæËçÓêØìâíçî­>讯è!%è"#è$%^Š&%j'(óô8ÅÝ66§Ì,¶,¶0:¹4™”¹×:6  §y ¹8:¹â+¶>™]6
§K
¹8¹â¶A:C¶GšI¶GšK¶G™
¹8¹âN-°„

¹O¡ÿ¯„              ¹O¡ÿ*+»òY·Q·öÆ*+»òY·Q·ö°„,¶T¡ÿ1°¬V     '   -
8FL
_ju€‘      ¯ÀÏÛ­zÝ®¯ÝUÝ'(V¾W%8kX%'ˆYZÚ[0Õ\]*…^]     IW_]
_2`8b
2*´S¹e+¹iM>§,¹l:¹oq¶>™ù¹i:6666     :
6§­¹l:¹os¶>™d¹×:

u¹Þ¹â¸{6
}¹Þ¹â¸{6
¹Þ¹â¸{6
¹Þ¹â¸{6  §3:§.¹oƒ¶>™¹â¶†:

ˆ¶>š
:
„¹‰¡ÿM*´S»‹Y
»Y   ··“¹•W„,¹‰¡þç±pÃ׬n%    '()+.,7-:.=/@0C1F3L4W7g8p;„<˜=¬>Ã@ÈDØEäGó3K$(1N­¢2®¯2!%"˜™\]š%7í›™:êt]=ç|]@ä~]Cá€]        FÞœ
I¹^]Wœ%pXžZ
ÅŸ ä¡
ÎÏ8éš²§©¶®+¹oN+¹×:+¹i:6§²§°¶³„h¡ÿﲧ»üY-¸··ÿ¹¶¶
¶³ÆY6§G²§»üY°·ÿ¹8¹o¶»¶¹8¹â¶¶¶
¶³„¹O¡ÿ³+¹âÆ%²§»üY½·ÿ+¹â¶¿¶¶
¶³²§¶Á6§*¹l`·Ñ„¹‰¡ÿäš²§©¶®±¬^RS
UVW$Z>]X`]acbfb‡cžb¤a³g¼hÞiälêmúl   o
pq­\      ®¯!%Â]œûžZ$óÙ'\]`S\]ç"\]Ä78m3*¶«*´·¹Á¹Æ*´·¹Á¹É*´·¹Á¹Í±¬{|}#~2­3®¯ÅÆ8>*+µȱ¬
…†­®¯ÉÊ78j4**´»¹ÎµÐ*´й×عÞ*´ä¹Ó**´»*´з×±¬Š‹'Œ3­4®¯ÔÕ8t$»ÙY½ÛY+SY,SYS·ÞN*´È-¹ä±¬‘#’­*$®¯$$%$&%åæçè85±¬–­®¯é*F8Ï+*µë+Ç+*µí*´·¹Á¹Æ*´·¹Áï¹É§ñ*´·¹óM+,¶ø¶ù¶ü™%+»üY,¶ø¶ù¸··ÿþ¶¶
ˆ¶L+¶/ *»õY+·µë§*»õY,¶ø+·
µë**´ë¸µí*´·¹Á¹Æ*´·¹Á»üY·ÿ+¶¶
¹É§RM*´·¹ú»üY·ÿ+¶¶
¹*´·¹Á¹Æ*´·¹Á»üY·ÿ+¶¶
¹É*´~*´í¶±1ÐЬZ £      ¤¥¦1«;¬I­k°u±„³”¶Ÿ·®¸ÐºÑ»Ú¼ì»ñ½¾Â*í*+®¯+;•#ÑNŸ8®V+¶$*´J¦**´A¶'µä*¶)+¶$*´N¦ *´+Æ*´+*´L¶'¶.**´+·0+¶$*´n¦**´+¶3±¬*
ÌÍÎÑ%Ò,Ó:ÔBØMÙUÛ­V®¯Vå4568_/+¶$*´~¦&*´íÆ*+¶;+¶>¶A*´`™±*´+ƪ*´+¶EM+¶;*´~¶Hd‡*´~¶LkJ+¶>*´~¶Od‡*´~¶Lk9)˜œJ˜œ9),¶RŽ‡c*´í¶W‡—›*´í¶W,¶RŽdd‡J,¶ZŽ‡c*´í¶\‡—›*´í¶\,¶ZŽdd‡9,)ŽŽ¶_*¶b§^*´b™²*´+Æ«*´+¶EM+¶;*´~¶Hd‡*´~¶LkJ+¶>*´~¶Od‡*´~¶Lk9),¶dg9,¶fg9        ˜œ9   ˜œ9       )*´í¶W‡—›*´í¶W‡,¶dg9*´í¶\‡—›*´í¶\‡,¶fg9      ,Ž  Ž¶i*¶b§¨+¶;*´~¶Hd‡*´~¶LkI+¶>*´~¶Od‡*´~¶Lk9(—›u—›n(*´í¶W‡˜œ`*´í¶\‡˜œQ*µb*»‹Y»Y+¶;*´~¶Hd‡*´~¶LkŽ+¶>*´~¶Od‡*´~¶LkŽ··“·l**´+¶o±¬ž'çèê,ë4ìJíaïiðsòˆóšô°õÃ÷ÌøÓúáûéüÿýþÿ'1;IYhx     ‚
‰
Ÿ¶àåæëï&.­z/®¯/åp4ŸqrJ‰tsar|sé qrÿŠtss|sk~s'b€s      Ÿts¶x|st68Ía+¶$*´~¦X*´íÆQ*+¶;+¶>¶A*+¶;+¶>·xM,Æ**´\¶|§(*+¶;+¶>·xN-Æ**´^¶|§**´Z¶|±¬*
"#%,'0(;+I-M.X1`5­*a®¯aåp,4}*I~*?”8|*´~¶Hd>*´~¶Od6››*´~¶£*´~¶„¤*´·¹Á¹Í§7‡*´~¶LkŽ6‡*´~¶LkŽ6*´·¹Á»†Y·‡¹Í±¬&     >
?A)B5DGGTHbJ{L­H|®¯|ˆ]|‰]
rt]g|]T'Š]b‹]Œ68c#+¶$*´~¦*´íÆ*+¶;+¶>·*¶b±¬UVW"Y­#®¯#åp68ÿ+¶$*´~¦v*´íÆo+¶“™*+¶;+¶>·–§Y*+¶;+¶>·xM,Æ**´\¶|*,·l*µ`§2*+¶;+¶>·xN-Æ**´^¶|*-·l*µb§**´Z¶|±¬>bcd(g6i:jBkGlOo]qarisntvw~|­*®¯åp6H}*]!~*—68x0+¶$*´~¦'*´íÆ +¶“™*+¶;+¶>·–*µ`*µb±¬‡ˆ‰%Œ*/­0®¯0åp˜685±¬—­®¯åp™68W+¶$*´~¦*´·¹Á¹Í±¬¢£¥­®¯åpmè8L*´S+¹•W*¶b±¬®¯°­®¯é*1è8]*´++¦*·l*´S+¹œW*¶b±¬¹
º»¼­®¯é*”8÷m*´~¶Hd‡*´~¶LkŽ>*´~¶Od‡*´~¶LkŽ6*·l6§-*´S¹ À‹:¶E¶¤™*·l§„*´S¹§¡ÿ˱¬*
ÆÇ)É.Ë4ÌDÎRÏXÐ[ËlÓ­Hm®¯mt]m|]YŠ])D‹]1;\]Dé*uv8…
Á*´~¶Hd‡*´~¶LkŽ6*´~¶Od‡*´~¶LkŽ6:6§€*´S¹ À‹:¶E:  ™- ¶dŽd¸­¢R    ¶fŽd¸­¢B:§L§8        ¶dŽ ¶RŽ`d¸­¢!   ¶fŽ ¶ZŽ`d¸­¢
:§„*´S¹§¡ÿx°¬Fàá*ã-å3æCçJéNê^ënírîxòó¦õªö­å¾û­f
Á®¯Át]Á|]Á®0¬Š]*—‹]-”¯*0Ž\]Cjé*Jcqr      ””8v(*·*¶b*´n*´+Ƨ¶²*´g*¶¶±¬

'­ (®¯(t](|]jè8x0*+µ+*´~+¶·*´+Ç*´Lˆ¶§*´L*´+¶º¶±¬
!/­0®¯0é*»¼PK
   u÷.©­–û%X%X6src/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.22 $
 *
 * Last modification: $Date: 2003/07/23 12:40:18 $
 * $Id: RegionEditorPlugin.java,v 1.22 2003/07/23 12:40:18 mdonner Exp $
 */

package src.plugins.regionEditorPlugin;

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

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.Node;

import javax.swing.JButton;
//import javax.swing.JFileChooser;
//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.parser.AdapterNode;


/**
 * The <code>RegionEditor</code> plugin shows and edits image regions.
 *
 * @author Yulia Klassen, Viktoriya Zudova
 *
 * @version $Revision: 1.22 $ Last modification: $Date: 2003/07/23 12:40:18 $
 */
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;

  /* 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");

  /* 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 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(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(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) {

        oldNode = node;
        gui.getStatusInterface().setIcon(StatusInterface.ICON_NONE);
        gui.getStatusInterface().setMessage(null);
        gui.getStatusInterface().setPoint(null);

         printTree(node, 0);
        if (node != null) {
          imageName = node.getAttributes().getNamedItem("image").getNodeValue();
        }
                
                imageUrl=null; // initialised
                TreePath workingPath = workingPath=elementPath.getParentPath();

                do {
                    // parent is set the parent of sleected element     
                    AdapterNode parent = (AdapterNode) workingPath.getLastPathComponent();
                    imageUrl = getUrlForLabel(imageName,parent);
                        workingPath=workingPath.getParentPath();
                
        }
                while(imageUrl==null && workingPath!=null); //if imageUrl can not be found on this level the search starts one level above again
                                                                                                        //if workingPath == null it can not be found in the whole document
                
        if (imageUrl==null) {
                gui.getLogInterface().log(LogInterface.TYPE_ERROR,"Picture "+"\""+imageName+"\""+" not found in document.");
        }
       
        

        imageNameField.setText(imageName);
        loadImage(imageUrl);

        // load existing regions
        initRegions(node);

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



        /** 
         * Tries to find the Url to the belonging Imagelabel among all children of 'parent'
         * 
         * @param label: The label of the Image
         * 
         * @param parent: The node among its children we search
         * 
         * @return The belonging Url. If it can not be found null is returned
         *
         * author Matthias Donner
         *
         * Last revision: 23-Jul-2003
         */

    private String getUrlForLabel(String label, AdapterNode parent) {
            String result;
                Node temp,attribTemp;
                NamedNodeMap nodeList;
                boolean exit = false;
                for (int i = 0; i<parent.childCount(); i++){ // we look at each child
                        temp=parent.getChild(i).toDomNode();
                        if (temp.hasAttributes()) {                             // if the child has attributes
                                nodeList=temp.getAttributes();
                                for (int j = 0; j< nodeList.getLength();j++){ // we look at each attribute
                                        attribTemp=nodeList.item(j);
                                        if (attribTemp.getNodeValue().equals(label)) { // if an attribute contains the label
                                                for (int k = 0; k<nodeList.getLength();k++){ // we look at all attributes again and try to find image urls
                                                        String attribute =nodeList.item(k).getNodeValue().toLowerCase();
                                                        if (attribute.endsWith(".jpg") || 
                                                                attribute.endsWith(".gif") ||
                                                                attribute.endsWith(".png")   ) {  // an image url always end with '.jpg', '.gif', or '.png'
                                                                        result = nodeList.item(k).getNodeValue();
                                                                        return result;  // returns the imageUrl
                                                                        
                                                        }                                       
                                                }   
                                        }
                                        
                                }
                        }
                        if (getUrlForLabel(label,new AdapterNode(temp))!=null) // searching in the childrens' children
                                return getUrlForLabel(label,new AdapterNode(temp));
                        
                }
                return null; // Url not found.
        }
                
                

    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;

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

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

              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;
            }
          }

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

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;
        }


  public void forceStatusReport() {
    changedNode = oldNode.cloneNode(true);
    changedNode.getAttributes().getNamedItem("image").setNodeValue(imageName);
    firePluginChangedElement(oldNode, changedNode);
  }

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

  private void sendRegionChanged(Region region)
  {
  }

  /**
   *  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();
    }

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

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


  /**
   * Invoked when a mouse button is pressed on a component.
   *
   * @see
   *
   * @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;
          setSelectedRegion(new Region(null, new Rectangle(
            (int)((e.getX() - imagePanel.getDx()) * imagePanel.getCoef()),
            (int)((e.getY() - imagePanel.getDy()) * imagePanel.getCoef()), 1, 1)));
          addRegion(selectedRegion);
        }
      }
    }
  }

  /**
   * Invoked when the mouse button 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 e mouse event
   */
  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 button 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 button 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());
                }

            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);
        }
        }

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

  /**
   * ...
   *
   * @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();
  }

  /**
   * ...
   *
   * @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;
      }
    }
  }

  /**
   * ...
   *
   * @param x             ...
   * @param y             ...
   * @param nordWest      ...
   *
   * @return
   */
  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;
  }

  /**
   * ...
   *
   * @param x             ...
   * @param y             ...
   */
  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
çnó.     'ƒÐæ5æ5>src/plugins/regionEditorPlugin/RegionEditorPluginTransform.xsl<!-- to-direction for RegionEditor
     status: not tested, should be not so long
     updated to given schema from 15/07/2003 
     Last Revision: 18/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="/">
        <xsl:apply-templates />
</xsl:template>


<xsl:template match="REGIONS"><!-- element-plugin association -->
        <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: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">
                                <!-- 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:copy-of select="self::node()" />
                                                </xsl:for-each>
                                                <!-- 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:element>
                                </xsl:for-each>
                                <xsl:for-each select="COORD_DATA">
                                        <xsl:element name="COORDS">
                                                <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:copy-of select="self::node()" />
                                                </xsl:for-each>
                                                <!-- 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: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:copy-of select="self::node()" />
                                        </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">
                                <!-- 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:copy-of select="self::node()" />
                                                </xsl:for-each>
                                        </xsl:element>
                                </xsl:for-each>
                                <!-- copy all other childs -->
                                <xsl:for-each select="node()">
                                        <xsl:if test = "not(name(.) = 'COORDS')">
                                                <xsl:copy-of select="self::node()" />
                                        </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">
                                <!-- 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:copy-of select="self::node()" />
                                                </xsl:for-each>
                                        </xsl:element>
                                </xsl:for-each>
                                <!-- copy all other childs -->
                                <xsl:for-each select="node()">
                                        <xsl:if test = "not(name(.) = 'COORDS')">
                                                <xsl:copy-of select="self::node()" />
                                        </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:copy-of select="self::node()" />
                        </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">
                                <!-- 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:copy-of select="self::node()" />
                                                </xsl:for-each>
                                                <!-- 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:element>
                                </xsl:for-each>
                                <xsl:for-each select="COORD_DATA">
                                        <xsl:element name="COORDS">
                                                <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:copy-of select="self::node()" />
                                                </xsl:for-each>
                                                <!-- 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: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:copy-of select="self::node()" />
                                        </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">
                                <!-- 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:copy-of select="self::node()" />
                                                </xsl:for-each>
                                        </xsl:element>
                                </xsl:for-each>
                                <!-- copy all other childs -->
                                <xsl:for-each select="node()">
                                        <xsl:if test = "not(name(.) = 'COORDS')">
                                                <xsl:copy-of select="self::node()" />
                                        </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">
                                <!-- 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:copy-of select="self::node()" />
                                                </xsl:for-each>
                                        </xsl:element>
                                </xsl:for-each>
                                <!-- copy all other childs -->
                                <xsl:for-each select="node()">
                                        <xsl:if test = "not(name(.) = 'COORDS')">
                                                <xsl:copy-of select="self::node()" />
                                        </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:copy-of select="self::node()" />
                        </xsl:if></xsl:if></xsl:if>
                </xsl:for-each>

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


</xsl:stylesheet>PK
ù|÷.
ˆWäÍ*Í*Bsrc/plugins/regionEditorPlugin/RegionEditorPluginTransformBack.xsl<!-- back-direction for RegionEditor
     status: not tested
     updated to given schema from 15/07/2003 
     Last Revision: 18/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="/">
        <xsl:apply-templates />
</xsl:template>


<xsl:template match="REGIONS"><!-- element-plugin association -->
        <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: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">
                                <!-- 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.
                                     With this information can the original element reconstructed.-->
                                <xsl:for-each select="COORDS">
                                        <xsl:variable name="temp" select="@XMLEditorSavedNameOfNode" />
                                        <xsl:element name="$temp">
                                                <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: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:copy-of select="self::node()" />
                                                </xsl:for-each>
                                        </xsl:element>
                                </xsl:for-each>

                                <!-- copy all other childs -->
                                <xsl:for-each select="node()">
                                        <xsl:if test = "not(name(.) = 'COORDS')">
                                                <xsl:copy-of select="self::node()" />
                                        </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">
                                <!-- 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:copy-of select="self::node()" />
                                                </xsl:for-each>
                                        </xsl:element>
                                </xsl:for-each>
                                <!-- copy all other childs -->
                                <xsl:for-each select="node()">
                                        <xsl:if test = "not(name(.) = 'COORDS')">
                                                <xsl:copy-of select="self::node()" />
                                        </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">
                                <!-- 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:copy-of select="self::node()" />
                                                </xsl:for-each>
                                        </xsl:element>
                                </xsl:for-each>
                                <!-- copy all other childs -->
                                <xsl:for-each select="node()">
                                        <xsl:if test = "not(name(.) = 'COORDS')">
                                                <xsl:copy-of select="self::node()" />
                                        </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:copy-of select="self::node()" />
                        </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">
                                <!-- 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.
                                     With this information can the original element reconstructed.-->
                                <xsl:for-each select="COORDS">
                                        <xsl:variable name="temp" select="@XMLEditorSavedNameOfNode" />
                                        <xsl:element name="$temp">
                                                <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: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:copy-of select="self::node()" />
                                                </xsl:for-each>
                                        </xsl:element>
                                </xsl:for-each>

                                <!-- copy all other childs -->
                                <xsl:for-each select="node()">
                                        <xsl:if test = "not(name(.) = 'COORDS')">
                                                <xsl:copy-of select="self::node()" />
                                        </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">
                                <!-- 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:copy-of select="self::node()" />
                                                </xsl:for-each>
                                        </xsl:element>
                                </xsl:for-each>
                                <!-- copy all other childs -->
                                <xsl:for-each select="node()">
                                        <xsl:if test = "not(name(.) = 'COORDS')">
                                                <xsl:copy-of select="self::node()" />
                                        </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">
                                <!-- 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:copy-of select="self::node()" />
                                                </xsl:for-each>
                                        </xsl:element>
                                </xsl:for-each>
                                <!-- copy all other childs -->
                                <xsl:for-each select="node()">
                                        <xsl:if test = "not(name(.) = 'COORDS')">
                                                <xsl:copy-of select="self::node()" />
                                        </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:copy-of select="self::node()" />
                        </xsl:if></xsl:if></xsl:if>
                </xsl:for-each>

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


</xsl:stylesheet>PK


}÷.        META-INF/þÊPK


}÷.ñÍSºMM+META-INF/MANIFEST.MFPK

{÷.‘ƒÖ»»/ªsrc/plugins/regionEditorPlugin/ImagePanel.classPK

Do÷.ÆL7Œ.²src/plugins/regionEditorPlugin/ImagePanel.javaPK

{÷.h®‘¡ÂÂ+!src/plugins/regionEditorPlugin/Region.classPK

Do÷.·`΂ÉÉ*(%src/plugins/regionEditorPlugin/Region.javaPK

{÷.ŸÙæKI;I;79*src/plugins/regionEditorPlugin/RegionEditorPlugin.classPK

   u÷.©­–û%X%X6×esrc/plugins/regionEditorPlugin/RegionEditorPlugin.javaPK

çnó.     'ƒÐæ5æ5>P¾src/plugins/regionEditorPlugin/RegionEditorPluginTransform.xslPK

ù|÷.
ˆWäÍ*Í*B’ôsrc/plugins/regionEditorPlugin/RegionEditorPluginTransformBack.xslPK

Œ¿