Subversion Repositories general

Rev

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

PK
öù.        META-INF/þÊPK
öù.·ÒMETA-INF/MANIFEST.MFManifest-Version: 1.0
Class-Path: 
Transform-To-File: src/plugins/imagePlugin/ImagePluginTransform.xsl
XMLEditor-Plugin-Name: ImageViewer
Created-By: 1.4.2 (Sun Microsystems Inc.)
Main-Class: src.plugins.imagePlugin.ImagePlugin
Description: ...(todo)
Transform-Fro-File: src/plugins/imagePlugin/ImagePluginTransformBack.x
 sl
Comment: you can view images with this plugin

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

PK
A‰ù.JÀ(=††(src/plugins/imagePlugin/ImagePanel.classÊþº¾-e"src/plugins/imagePlugin/ImagePaneljavax/swing/JPanelimageLjava/awt/Image;dxIdy
imageWidthimageHeightcoefD<init>()VCode(Z)V
LineNumberTableLocalVariableTablethis$Lsrc/plugins/imagePlugin/ImagePanel;paintComponent(Ljava/awt/Graphics;)Vjavax/swing/JComponentgetWidth()I
  getHeight 
!java/awt/Component#
getBackground()Ljava/awt/Color;%&
$'java/awt/Graphics)setColor(Ljava/awt/Color;)V+,
*-fillRect(IIII)V/0
*1       3java/awt/Image5!(Ljava/awt/image/ImageObserver;)I7
68 7
6:java/lang/Math<max(DD)D>?
=@
       B       D        F
      H       J  drawImage5(Ljava/awt/Image;IIIILjava/awt/image/ImageObserver;)ZLM
*NgLjava/awt/Graphics;whiwihkxkysetImage(Ljava/awt/Image;)VrepaintZ
$[getCoef()DgetDxgetDy
getImageWidthgetImageHeight
SourceFileImagePanel.java        

4*·±
67j
®*¶=*¶">+*¶(¶.+¶2*´4Ə*´4¶96*´4¶;6‡‡o9‡‡o9*¸AµC*´C˜œ*µC§‡*´CoŽ6‡*´CoŽ6*dlµE*dlµG*µI*µK+*´4*´E*´G¶OW±R?@
CDG!J+K5L=MEOPQYRaTlUwXY‹Z‘[—^­`R®®PQ©R
¤S+‚T5xU=pV
EhW
XYF
*+µ4*¶\±hi      j

]^/*´C¯u_/*´E¬`/*´G¬‰a/*´I¬’b/*´K¬›cdPK
U|ø.tfǨÄÄ'src/plugins/imagePlugin/ImagePanel.java/*
 * This file contains the ImagePanel class.
 *
 * Coded by: Group 5, software practice summer 2003
 * University of Bielefeld, Germany
 *
 * @version $Revision: 1.12 $
 *
 * Last modification: $Date: 2003/07/24 13:34:43 $
 * $Id: ImagePanel.java,v 1.12 2003/07/24 13:34:43 hjokusch Exp $
 */

package src.plugins.imagePlugin;

import java.awt.Graphics;
import java.awt.Image;

import javax.swing.JPanel;

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

        /** The current image. */
        private Image image;
        
        /** The dx-shift of an image in relation to the left top corner of plugin panel. */
        private int dx;
        
        /** The dy-shift of an image in realtion to the left top corner of plugin panel. */
        private int dy;
        
        /** The width of the image. */
        private int imageWidth;
        
        /** The height of the image. */
        private int imageHeight;

        /* The scale coef (acronym for coeffiecient)of the image. */
    private double coef;

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

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

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


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

    public double getCoef() {
                return coef;
    }

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

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

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

        /** 
         * Returns the height of the current image.
         *
         * @return The height of the current image. 
         */
        public int getImageHeight()     {
                return imageHeight;
        }
}PK
A‰ù.ã´qª"ª")src/plugins/imagePlugin/ImagePlugin.classÊþº¾-Õ#src/plugins/imagePlugin/ImagePluginjavax/swing/JPanelsrc/plugins/PluginInterfacejava/awt/event/ActionListener"java/awt/event/MouseMotionListener    java/awt/event/MouseListener
pluginNameLjava/lang/String;
ConstantValueImageViewerimageLjava/awt/Image;imageNameFieldLjavax/swing/JTextField;
confirmButtonLjavax/swing/JButton;imageFileLabelLjavax/swing/JLabel;fileChooserLjavax/swing/JFileChooser;openFileButton
imagePanel$Lsrc/plugins/imagePlugin/ImagePanel;guiLsrc/gui/GuiInterface;ourEventListenerLsrc/control/OurEventListener;  imageNameimageUrlcurrentFileLjava/io/File;oldNodeLorg/w3c/dom/Node;changedNode<init>()VCode*+
-
       /javax/swing/JTextField1
2-       4javax/swing/JButton6Confirm8(Ljava/lang/String;)V*:
7;       =javax/swing/JLabel?
@-       Bjavax/swing/JFileChooserD
E-       GOpen...I  K"src/plugins/imagePlugin/ImagePanelM
N-       Pjava/awt/BorderLayoutR
S-java/awt/ContainerU  setLayout(Ljava/awt/LayoutManager;)VWX
VYjava/awt/Component[addMouseListener!(Ljava/awt/event/MouseListener;)V]^
\_addMouseMotionListener'(Ljava/awt/event/MouseMotionListener;)Vab
\cadd*(Ljava/awt/Component;)Ljava/awt/Component;ef
VgEasti)(Ljava/awt/Component;Ljava/lang/Object;)Vek
Vljava/awt/Dimensionn(II)V*p
oqjavax/swing/JComponentssetPreferredSize(Ljava/awt/Dimension;)Vuv
twNorthyjavax/swing/AbstractButton{addActionListener"(Ljava/awt/event/ActionListener;)V}~
|
setVisible(Z)V‚
tƒLineNumberTableLocalVariableTablethis%Lsrc/plugins/imagePlugin/ImagePlugin;   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(I)VžœŸ
setMessage¡:œ¢setPoint(Ljava/awt/Point;)V¤¥œ¦java/lang/System¨outLjava/io/PrintStream;ª«      ©¬java/lang/StringBuffer®ImagePlugin gets node: °
¯;append,(Ljava/lang/Object;)Ljava/lang/StringBuffer;³´
¯µtoString()Ljava/lang/String;·¸
¯¹java/io/PrintStream»println½:
¼¾new node is "null"À
new node: Âname: Äorg/w3c/dom/NodeÆgetNodeNameȸÇÉ,(Ljava/lang/String;)Ljava/lang/StringBuffer;³Ë
¯ÌprintÎ:
¼Ï; attributes: Ñ
getAttributes()Lorg/w3c/dom/NamedNodeMap;ÓÔÇÕ "×org/w3c/dom/NamedNodeMapÙitem(I)Lorg/w3c/dom/Node;ÛÜÚÝ"=ßgetNodeValueá¸Çâ   getLength()IäåÚæ½+
¼èNode has attributes: ê
hasAttributes()ZìíÇî(Z)Ljava/lang/StringBuffer;³ð
¯ñnameógetNamedItem&(Ljava/lang/String;)Lorg/w3c/dom/Node;õöÚ÷#    ùurlû$    ý
imageUrl: ÿjavax/swing/text/JTextComponentsetText:
  loadImage:
setPluginPanel(Ljavax/swing/JPanel;)V       
–nodeenvironmentLorg/w3c/dom/Document;elementPathLjavax/swing/tree/TreePath;lLorg/w3c/dom/NamedNodeMap;iInodeAttrstopsetOurEventListener!(Lsrc/control/OurEventListener;)V!"     newListenerforceStatusReport        cloneNode(Z)Lorg/w3c/dom/Node;Ç )(       "setNodeValue$:Ç%Changed node: 'java/lang/Object)
*¹firePluginChangedElement'(Lorg/w3c/dom/Node;Lorg/w3c/dom/Node;)V,-
.src/control/OurEvent0([Ljava/lang/Object;)V*2
13src/control/OurEventListener5
firedOurEvent(Lsrc/control/OurEvent;)V7869eLsrc/control/OurEvent;%&  =       ?No imageAgetCurrentFile()Ljava/io/File;CD–Ejava/io/FileG
getParentFileID
HJ
H¹java/lang/StringM
startsWith(Ljava/lang/String;)ZOP
NQvalueOf&(Ljava/lang/Object;)Ljava/lang/String;ST
NU/WYreplaceFirst8(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;[\
N]charAt(I)C_`
Na
H;#(Ljava/io/File;Ljava/lang/String;)V*d
Hejavax/imageio/ImageIOgread.(Ljava/io/File;)Ljava/awt/image/BufferedImage;ij
hkShow image from mgetLogInterface()Lsrc/gui/LogInterface;op–qCannot open file ssrc/gui/LogInterfaceulog(ILjava/lang/String;)Vwxvy
@setImage(Ljava/awt/Image;)V|}
N~java/io/IOException€fileNamedocexLjava/io/IOException;actionPerformed(Ljava/awt/event/ActionEvent;)Vjava/util/EventObjectˆ getSource()Ljava/lang/Object;Š‹
‰ŒgetTextŽ¸
+
‘setSelectedFile(Ljava/io/File;)V“”
E•
getMainWindow()Ljava/awt/Frame;—˜–™showOpenDialog(Ljava/awt/Component;)I›œ
EgetSelectedFileŸD
E getPath¢¸
H£Ljava/awt/event/ActionEvent;mouseDragged(Ljava/awt/event/MouseEvent;)Vjava/awt/event/MouseEvent¨getXªå
©«getY­å
©®        showMouse°p
±Ljava/awt/event/MouseEvent;
mouseMovedgetDxµå
N¶getDy¸å
N¹
getImageWidthȌ
N¼getImageHeight¾å
N¿getCoef()DÁÂ
NÃjava/awt/PointÅ
ÆqmouseXmouseYxyxxyymouseClickedmousePressed
mouseReleasedmouseEnteredmouseExited
SourceFileImagePlugin.java!

 !"#$%&'()(*+,É
*·.*µ0*»2Y·3µ5*»7Y9·<µ>*»@Y·AµC*»EY·FµH*»7YJ·<µL*»NY·OµQ*»SY·T¶Z*´Q*¶`*´Q*¶d»Y·.L+»SY·T¶Z+*´5¶hW+*´>j¶m»Y·.M,»oYð·r¶x,»SY·T¶Z,*´C¶hW,*´Lj¶m»Y·.N-»SY·T¶Z-+¶hW-,j¶m*-z¶m**´Q¶hW*´>*¶€*´L*¶€*¶„±…zn>
DG"J-M8PESPq[rcskvsw~x‡y‘}™~©´€½Ç„Ï…Ú†à‡ç‰îŠ÷Œÿ†*
‡ˆsš‰Š™t‹ŠÏ>ŒŠŽ,>*+µ±…
˜™†‡ˆ ‘’,=g*+µ”*´¹š¹ *´¹š¹£*´¹š¹§²­»¯Y±·²+¶¶¶º¶¿+Dz­Á¶¿§ð²­ö¿²­»¯YÅ·²+¹Ê¶Í¶º¶Ð²­Ò¶Ð+¹Ö:ÆQ6§?²­»¯YØ·²¹Þ¹Ê¶Íà¶Í¹Þ¹ã¶Í¶º¶Ð„¹ç¡ÿ»²­¶é²­»¯Yë·²+¹ï¶ò¶º¶¿+¹Ö:*ô¹ø¹ãµú*ü¹ø¹ãµþ²­»¯Y·²*´þ¶Í¶º¶¿*´5*´ú¶**´þ·*´*¹*¶„±…v¤§¨#©2«H­L®W²_³z´‚µŠ¶·•¸˜¸²¹È¸Î·Ý¼ã¾þ¿ÀÁ*ÂDÅOÆWÈaÉfʆHg‡ˆg
(ggŠº’K>+,m3*¶„*´¹š¹ *´¹š¹£*´¹š¹§±…ÐÑÒ#Ó2Ԇ3‡ˆ,>*+µ±…
Úۆ‡ˆ"+,¨j**´”¹!µ#*´#¹Öü¹ø*´þ¹&*´#¹Öô¹ø*´ú¹&²­»¯Y(·²*´#¶+¶Í¶º¶¿**´”*´#·/±…æç'è@é]êië†j‡ˆ,-,t$»1Y½*Y+SY,SYS·4N*´-¹:±…îï#ð†*$‡ˆ$'($)(;<:,ä8*µ>+Ç+*µ@*´¹š¹ *´¹šB¹£§ñ*´¹FM+,¶K¶L¶R™%+»¯Y,¶K¶L¸V·²X¶Í¶ºZ¶^L+¶b/ *»HY+·cµ>§*»HY,¶K+·fµ>**´>¸lµ@*´¹š¹ *´¹š»¯Yn·²+¶Í¶º¹£§RM*´¹r»¯Yt·²+¶Í¶º¹z*´¹š¹ *´¹š»¯Yt·²+¶Í¶º¹£*+µþ*´C+¶{*´Q*´@¶±1ÐЁ…búý    þÿ1;Ik     u
„”Ÿ®ÐÑÚìñ$,7†*8‡ˆ8‚;•ƒ&ÑN„…†‡,­Y+¶*´>¦*´úÆ**´5¶µú*¶’+¶*´L¦/*´H*´>¶–*´H*´¹š¶žš**´H¶¡¶¤·±…&   &(*+!/,173J6X=†Y‡ˆY;¥¦§,[+¶*´Q¦*´@Æ*+¶¬+¶¯¶²±…IJL†‡ˆ;³´§,[+¶*´Q¦*´@Æ*+¶¬+¶¯¶²±…WXZ†‡ˆ;³°p,|*´Q¶·d>*´Q¶ºd6››*´Q¶½£*´Q¶À¤*´¹š¹§§7‡*´Q¶ÄkŽ6‡*´Q¶ÄkŽ6*´¹š»ÆY·ǹ§±…&       d
eg)h5jGnTobq{s†H|‡ˆ|È|É
rÊgËT'ÌbÍΧ,5±…{†‡ˆ;³Ï§,5±…ƒ†‡ˆ;³Ð§,5±…‹†‡ˆ;³Ñ§,5±…“†‡ˆ;³Ò§,W+¶*´Q¦*´¹š¹§±…ž †‡ˆ;³ÓÔPK
Cù.‰k²EÁ,Á,(src/plugins/imagePlugin/ImagePlugin.java/*
 * This file contains the ImagePlugin class.
 *
 * Coded by: Group 5, software practice summer 2003
 * University of Bielefeld, Germany
 *
 * @version $Revision: 1.28 $
 *
 * Last modification: $Date: 2003/07/24 22:18:06 $
 * $Id: ImagePlugin.java,v 1.28 2003/07/24 22:18:06 ioklasse Exp $
 */

package src.plugins.imagePlugin;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Image;

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.awt.Point;

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

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 org.apache.xpath.XPathAPI;
//import java.util.Map;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Document;
import org.w3c.dom.Node;

//import javax.xml.transform.TransformerException;

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

/**
 * The image plugin shows images of the type JPEG, GIF and PNG.
 *
 * @author Yulia Klassen, Viktoriya Zudova
 * 
 * @version $Revision: 1.28 $ Last modification: $Date: 2003/07/24 22:18:06 $
 */
public class ImagePlugin extends JPanel
  implements PluginInterface, ActionListener,
  MouseMotionListener, MouseListener {

  /** Name of the plugin, used in method <code>firePluginChangedElement</code> */
  final private String pluginName = "ImageViewer";

  /** 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 and url in the node. */
  private JButton confirmButton = new JButton("Confirm");

  /** A label to show the name of the current image file. */
  private JLabel imageFileLabel = new JLabel();

  /** A file chooser to choose an image file. */
  private JFileChooser fileChooser = new JFileChooser();

  /** A button "Open..." to change images. */
  private JButton openFileButton = new JButton("Open...");

  /** An image panel to show an image in. */
  private ImagePanel imagePanel = new 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 class constructor creates all GUI elements for the image plugin, registers
   * the necessary listeners and displays it.
   */
  public ImagePlugin() {

        // Sets new layout.
        setLayout(new BorderLayout());
        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 image file,
        //              open button to change images.
        JPanel rightPanel = new JPanel();
        rightPanel.setPreferredSize(new Dimension(240, 24));
        rightPanel.setLayout(new BorderLayout());
        rightPanel.add(imageFileLabel);
        rightPanel.add(openFileButton, 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);
        openFileButton.addActionListener(this);

        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 element The element that the user has chosen.
   * @param environment The current document.
   * @param elementPath The <code>TreePath</code> of the selected element in the evironment.
   */
  public void start(Node node, Document environment, TreePath elementPath) {
        // TODO comment
        oldNode = node;
        
        /* Clear the status panel. */
        gui.getStatusInterface().setIcon(StatusInterface.ICON_NONE);
        gui.getStatusInterface().setMessage(null);
        gui.getStatusInterface().setPoint(null);

        System.out.println("ImagePlugin gets node: " + node);

        if (node == null) {
                System.out.println("new node is \"null\"");
        }

        else {
                System.out.println("new node: ");
                System.out.print("name: " + node.getNodeName());
                System.out.print("; attributes: ");
                NamedNodeMap l = node.getAttributes();
                if (l != null) {
                        for (int i = 0; i < l.getLength(); i++) {
                                System.out.print(" \"" + l.item(i).getNodeName()
                                                                + "\"=" + l.item(i).getNodeValue());
                        }
                }
                System.out.println();

                System.out.println("Node has attributes: " + node.hasAttributes());
                NamedNodeMap nodeAttr = node.getAttributes();
                imageName = nodeAttr.getNamedItem("name").getNodeValue();
                imageUrl = nodeAttr.getNamedItem("url").getNodeValue();
                System.out.println("imageUrl: " + imageUrl);
        }

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

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

        /**
         * Stops the plugin by setting it invisible and clearing the status panel.
         */
        public void stop() {
                setVisible(false);
                gui.getStatusInterface().setIcon(StatusInterface.ICON_NONE);
                gui.getStatusInterface().setMessage(null);
                gui.getStatusInterface().setPoint(null);
        }

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

        /**
         * Forces the text editor plugin to return the actual status as a node, 'cause
         * not well-formed parts have to be capsuled into a prosessing instruction.
         *
         * @see src.gui.PluginInterface#forceStatusReport()
         */
        public void forceStatusReport() {
                
                
                changedNode = oldNode.cloneNode(true);
                changedNode.getAttributes().getNamedItem("url").setNodeValue(imageUrl);
                changedNode.getAttributes().getNamedItem("name").setNodeValue(imageName);
                System.out.println("Changed node: " + changedNode.toString());
                firePluginChangedElement(oldNode, changedNode);
        }

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

  /**
   *  Loads image.
   *
   *  @param fileName The file name of the image to be loaded.
   */
  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");
        }
        // Get 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);
          }
        }
        imageUrl = fileName;
        imageFileLabel.setText(fileName);
        imagePanel.setImage(image);
  }

  /**
   *  Reaction of all buttons.
   *
   *  @param e  Some event.
   */
  public void actionPerformed(ActionEvent e) {

        if(e.getSource() == confirmButton) {

          if(imageName != null) {

                imageName = imageNameField.getText();
                forceStatusReport();
          }
        }

        if(e.getSource() == openFileButton) {

          fileChooser.setSelectedFile(currentFile);

          if(fileChooser.showOpenDialog(gui.getMainWindow())
                == JFileChooser.APPROVE_OPTION) {

                loadImage(fileChooser.getSelectedFile().getPath());
                //imageUrl = fileChooser.getSelectedFile().getPath();
                /*if(imageUrl != null) {
                  imageUrl = currentFile.getPath();
                }*/
          }
        }
  }


        /**
         * Invoked when a mouse is pressed while on a component.
         *
         * @param e A mouse event indicating that a mouse button has been pressed
         * on a component and then dragged.
         * 
         * @see java.awt.event.MouseMotionListener#mouseDragged
         */
        public void mouseDragged(MouseEvent e) {
                if(e.getSource() == imagePanel && image != null) {
                        showMouse(e.getX(), e.getY());
                }
        }

        /**
         * Invoked when the mouse has been moved onto a component (with no button pressed).
         *
         * @param e A mouse event indicating that the cursor has been moved into a component
         * without pressing a button.
         * 
         * @see java.awt.event.MouseMotionListener#mouseMoved
         */
        public void mouseMoved(MouseEvent e) {
                if(e.getSource() == imagePanel && image != null) {
                        showMouse(e.getX(), e.getY());
                }
        }

    /**
     * Shows the current position of mouse.
     *
     * @param mouseX: Position of mouse.
     * @param mouseY: Position of mouse.
     */
    public void showMouse(int mouseX, int mouseY) {

          int x = mouseX - imagePanel.getDx();
          int y = mouseY - imagePanel.getDy();

          if(x < 0 || y < 0 || x > imagePanel.getImageWidth()
            || y > imagePanel.getImageHeight()) {

            gui.getStatusInterface().setPoint(null);
          }

          else {
          int xx = (int)(x * imagePanel.getCoef());
          int yy = (int)(y * imagePanel.getCoef());

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

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

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

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

        /**
         * 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.
     * 
     * @see java.awt.event.MouseListener#mouseExited
     *
     * @param e A mouse event indicating that a component has been left.
     */
    public void mouseExited(MouseEvent e) {
                if(e.getSource() == imagePanel) {
                        gui.getStatusInterface().setPoint(null);
                }
        }
}PK
ðhù.VI+ê¥
¥
0src/plugins/imagePlugin/ImagePluginTransform.xsl<!-- to-direction for pictureviewer
     status: problems with namespace and comments
     updated to given schema from 15/07/2003 
     Last Revision: 25/07/2003 by Sascha Walkenhorst -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />


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

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

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

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

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

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

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


</xsl:stylesheet>PK
ðhù.u5æß     ß    4src/plugins/imagePlugin/ImagePluginTransformBack.xsl<!-- back-direction for pictureviewer
     status: problems with namespace and comments
     updated to given schema from 15/07/2003 
     Last Revision: 25/07/2003 by Sascha Walkenhorst -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />


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

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

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

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


</xsl:stylesheet>PK

öù.        META-INF/þÊPK

öù.·Ò+META-INF/MANIFEST.MFPK

A‰ù.JÀ(=††(^src/plugins/imagePlugin/ImagePanel.classPK

U|ø.tfǨÄÄ'*src/plugins/imagePlugin/ImagePanel.javaPK

A‰ù.ã´qª"ª")3src/plugins/imagePlugin/ImagePlugin.classPK

Cù.‰k²EÁ,Á,($;src/plugins/imagePlugin/ImagePlugin.javaPK

ðhù.VI+ê¥
¥
0+hsrc/plugins/imagePlugin/ImagePluginTransform.xslPK

ðhù.u5æß     ß    4ssrc/plugins/imagePlugin/ImagePluginTransformBack.xslPK•O}