Subversion Repositories general

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
240 swalkenh 1
PK
813 swalkenh 2
 
3
 
4
Class-Path: 
240 swalkenh 5
Transform-To-File: src/plugins/imagePlugin/ImagePluginTransform.xsl
813 swalkenh 6
XMLEditor-Plugin-Name: ImageViewer
7
Created-By: 1.4.2 (Sun Microsystems Inc.)
8
Main-Class: src.plugins.imagePlugin.ImagePlugin
240 swalkenh 9
Description: ...(todo)
10
Transform-Fro-File: src/plugins/imagePlugin/ImagePluginTransformBack.x
11
 sl
813 swalkenh 12
Comment: you can view images with this plugin
240 swalkenh 13
 
14
Name: src/plugins/imagePlugin
813 swalkenh 15
Specification-Title: plugin for XMLEditor
16
Implementation-Title: src.plugins.imagePlugin
240 swalkenh 17
Specification-Version: 0.4 (05/07/03)
813 swalkenh 18
Specification-Vendor: group5, software practice SS_2003, University Bi
19
 elefeld, Germany
240 swalkenh 20
Implementation-Version: 0.2 (05/07/03)
21
Implementation-Vendor: group5, software practice SS_2003, University B
22
 ielefeld, Germany
23
 
24
PK
813 swalkenh 25
 
26
imageWidthimageHeightcoefD<init>()VCode(Z)V
27
 
28
 
29
 
30
$'java/awt/Graphics)setColor(Ljava/awt/Color;)V+,
31
 
32
 
33
 
34
 
35
 
36
 
37
 
38
 
39
 
40
 
279 swalkenh 41
67j
813 swalkenh 42
®*¶=*¶">+*¶(¶.+¶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?@
43
 
44
 
45
 
46
 
47
 
48
 
49
 
50
 
51
 * Coded by: Group 5, software practice summer 2003
52
 
53
 
54
 
521 swalkenh 55
 *
813 swalkenh 56
 * Last modification: $Date: 2003/07/24 13:34:43 $
521 swalkenh 57
 * $Id: ImagePanel.java,v 1.12 2003/07/24 13:34:43 hjokusch Exp $
58
 */
59
813 swalkenh 60
package src.plugins.imagePlugin;
61
62
import java.awt.Graphics;
63
import java.awt.Image;
521 swalkenh 64
813 swalkenh 65
 
521 swalkenh 66
67
 
68
 * Image panel shows any image.
69
 *
70
 
71
 * 
72
 
73
 */
813 swalkenh 74
class ImagePanel extends JPanel {
521 swalkenh 75
813 swalkenh 76
	/** The current image. */
77
	private Image image;
78
	
521 swalkenh 79
	/** The dx-shift of an image in relation to the left top corner of plugin panel. */
813 swalkenh 80
	private int dx;
81
 
82
	/** The dy-shift of an image in realtion to the left top corner of plugin panel. */
83
	private int dy;
84
 
85
	/** The width of the image. */
521 swalkenh 86
	private int imageWidth;
813 swalkenh 87
 
88
	/** The height of the image. */
521 swalkenh 89
	private int imageHeight;
813 swalkenh 90
 
91
	/* The scale coef (acronym for coeffiecient)of the image. */
521 swalkenh 92
    private double coef;
813 swalkenh 93
 
94
	/**
521 swalkenh 95
	 * The class constructor invokes <code>JPanel</code> to create all elements
96
 
813 swalkenh 97
	 *
98
	 * @see javax.swing.JPanel
521 swalkenh 99
 
813 swalkenh 100
	public ImagePanel() {
101
		super(true);
102
	}
103
104
	/** 
105
	 * <code>paintComponent</code> draws the image.
106
	 * 
521 swalkenh 107
	 * @see javax.swing.JComponent#paintComponent
108
	 */
109
 
813 swalkenh 110
		int w  = getWidth();
111
		int h  = getHeight();
112
113
		/* Fill the background. */
114
		g.setColor(getBackground());
115
		g.fillRect(0, 0, w, h);
521 swalkenh 116
117
		/* If there is an image ... */
118
 
813 swalkenh 119
			
521 swalkenh 120
			/* Calculate the size and position of the image. */
121
			int iw = image.getWidth(null);
122
 
813 swalkenh 123
			double kx = (double)iw/w;
124
			double ky = (double)ih/h;
125
 
126
			coef = Math.max(kx, ky);
521 swalkenh 127
128
            if(coef < 1) {
129
                coef = 1;
130
            } else {
131
 
813 swalkenh 132
				ih = (int)(ih/coef);
521 swalkenh 133
 
813 swalkenh 134
135
			dx = (w-iw)/2;
136
			dy = (h-ih)/2;
137
            imageWidth = iw;
138
            imageHeight = ih;
139
140
 
521 swalkenh 141
			g.drawImage(image, dx, dy, iw, ih, null);
142
		}
813 swalkenh 143
	}
144
521 swalkenh 145
 
813 swalkenh 146
	 * Sets the currently visible image to the image given as parameter.
521 swalkenh 147
	 * 
148
	 * @param image: The image to display.
149
	 */
150
 
813 swalkenh 151
		this.image = image;
152
		repaint();
153
	}
154
155
156
	/**
521 swalkenh 157
 	* The methode <code> getCoef </code> retuns the double for 
158
 	* scaling the image
159
 	* 
160
 
813 swalkenh 161
 
162
163
    public double getCoef() {
164
		return coef;
165
    }
166
167
	/** 
168
 
169
	 * corner of the plugin panel.
170
	 * 
171
	 * @return The difference on the x-axis. 
172
 
173
	public int getDx() {
174
		return dx;
175
	}
176
177
	/** 
178
	 * Returns the dy-shift of an image according to the left top
179
	 * corner of the plugin panel.
521 swalkenh 180
	 * 
181
	 * @return The difference on the y-axis.
182
 
813 swalkenh 183
	public int getDy() {
184
		return dy;
185
	}
186
187
	/**
188
	 * Returns the width of the current image.
189
	 * 
521 swalkenh 190
	 * @return The width of the current image.
191
	 */
192
 
813 swalkenh 193
		return imageWidth;
194
	}
195
196
	/** 
197
	 * Returns the height of the current image.
198
	 *
521 swalkenh 199
	 * @return The height of the current image. 
200
	 */
201
 
813 swalkenh 202
		return imageHeight;
203
	}
204
}PK
205
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
206
pluginNameLjava/lang/String;
ConstantValueImageViewerimageLjava/awt/Image;imageNameFieldLjavax/swing/JTextField;
confirmButtonLjavax/swing/JButton;imageFileLabelLjavax/swing/JLabel;fileChooserLjavax/swing/JFileChooser;openFileButton
207
imagePanel$Lsrc/plugins/imagePlugin/ImagePanel;guiLsrc/gui/GuiInterface;ourEventListenerLsrc/control/OurEventListener;	imageNameimageUrlcurrentFileLjava/io/File;oldNodeLorg/w3c/dom/Node;changedNode<init>()VCode*+
521 swalkenh 208
-
	/javax/swing/JTextField1
209
2-	4javax/swing/JButton6Confirm8(Ljava/lang/String;)V*:
348 swalkenh 210
7;	=javax/swing/JLabel?
813 swalkenh 211
 
521 swalkenh 212
E-	GOpen...I	K"src/plugins/imagePlugin/ImagePanelM
607 swalkenh 213
N-	Pjava/awt/BorderLayoutR
214
S-java/awt/ContainerU	setLayout(Ljava/awt/LayoutManager;)VWX
215
VYjava/awt/Component[addMouseListener!(Ljava/awt/event/MouseListener;)V]^
216
 
217
 
218
 
219
 
220
 
221
 
222
 
223
 
224
 
225
 
226
 
227
 
228
 
229
 
230
 
231
 
232
¯ÌprintÎ:
233
 
813 swalkenh 234
¼èNode has attributes: ê
hasAttributes()ZìíÇî(Z)Ljava/lang/StringBuffer;³ð
607 swalkenh 235
¯ñnameógetNamedItem&(Ljava/lang/String;)Lorg/w3c/dom/Node;õöÚ÷#	ùurlû$	ý
236
 
237
 
238
 
239
 
240
*¹firePluginChangedElement'(Lorg/w3c/dom/Node;Lorg/w3c/dom/Node;)V,-
241
 
242
 
243
HJ
244
 
245
startsWith(Ljava/lang/String;)ZOP
246
 
247
NU/WYreplaceFirst8(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;[\
248
N]charAt(I)C_`
249
 
813 swalkenh 250
 
251
Hejavax/imageio/ImageIOgread.(Ljava/io/File;)Ljava/awt/image/BufferedImage;ij
252
 
253
@setImage(Ljava/awt/Image;)V|}
254
N~java/io/IOException€fileNamedocexLjava/io/IOException;actionPerformed(Ljava/awt/event/ActionEvent;)Vjava/util/EventObjectˆ	getSource()Ljava/lang/Object;Š‹
255
‰ŒgetTextŽ¸
256
+
257
‘setSelectedFile(Ljava/io/File;)V“”
258
E•
getMainWindow()Ljava/awt/Frame;—˜–™showOpenDialog(Ljava/awt/Component;)I›œ
259
EgetSelectedFileŸD
260
E getPath¢¸
261
H£Ljava/awt/event/ActionEvent;mouseDragged(Ljava/awt/event/MouseEvent;)Vjava/awt/event/MouseEvent¨getXªå
262
©«getY­å
263
©®	showMouse°p
264
±Ljava/awt/event/MouseEvent;
265
mouseMovedgetDxµå
266
 
267
 
268
N¼getImageHeight¾å
269
N¿getCoef()DÁÂ
270
 
271
 
272
SourceFileImagePlugin.java!
273
 
274
 
275
˜™†‡ˆ ‘’,=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‡ˆ,>*+µ±…
276
Úۆ‡ˆ"+,¨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
277
„”Ÿ®ÐÑÚìñ$,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
278
 
279
rÊgËT'ÌbÍΧ,5±…{†‡ˆ;³Ï§,5±…ƒ†‡ˆ;³Ð§,5±…‹†‡ˆ;³Ñ§,5±…“†‡ˆ;³Ò§,W+¶*´Q¦*´¹š¹§±…ž †‡ˆ;³ÓÔPK
280
 
281
 
282
 *
283
 
284
 
285
 
286
 * @version $Revision: 1.28 $
279 swalkenh 287
 *
288
 * Last modification: $Date: 2003/07/24 22:18:06 $
607 swalkenh 289
 
290
 
813 swalkenh 291
292
 
607 swalkenh 293
 
813 swalkenh 294
 
295
 
296
 
297
 
298
import java.awt.event.ActionEvent;
299
 
300
 
521 swalkenh 301
import java.awt.event.MouseListener;
813 swalkenh 302
import java.awt.event.MouseMotionListener;
521 swalkenh 303
import java.awt.Point;
304
305
import java.io.File;
813 swalkenh 306
import java.io.IOException;
307
308
import javax.swing.JButton;
309
import javax.swing.JFileChooser;
327 swalkenh 310
import javax.swing.JLabel;
279 swalkenh 311
 
312
import javax.swing.JTextField;
313
 
521 swalkenh 314
import javax.swing.tree.TreePath;
315
316
//import org.apache.xpath.XPathAPI;
317
 
318
import org.w3c.dom.NamedNodeMap;
319
import org.w3c.dom.Document;
320
import org.w3c.dom.Node;
321
322
//import javax.xml.transform.TransformerException;
323
324
 
325
import src.control.OurEventListener;
326
import src.gui.*;
327
 
813 swalkenh 328
329
/**
330
 * The image plugin shows images of the type JPEG, GIF and PNG.
331
 *
332
 * @author Yulia Klassen, Viktoriya Zudova
333
 
334
 * @version $Revision: 1.28 $ Last modification: $Date: 2003/07/24 22:18:06 $
335
 
521 swalkenh 336
public class ImagePlugin extends JPanel
327 swalkenh 337
  implements PluginInterface, ActionListener,
521 swalkenh 338
  MouseMotionListener, MouseListener {
339
340
  /** Name of the plugin, used in method <code>firePluginChangedElement</code> */
279 swalkenh 341
 
521 swalkenh 342
343
 
348 swalkenh 344
  private Image image;
345
279 swalkenh 346
  /** A text field to enter the name of an image. */
348 swalkenh 347
  private JTextField imageNameField = new JTextField();
279 swalkenh 348
 
349
  /** A button "Confirm" to change the image name and url in the node. */
813 swalkenh 350
  private JButton confirmButton = new JButton("Confirm");
327 swalkenh 351
521 swalkenh 352
  /** A label to show the name of the current image file. */
813 swalkenh 353
  private JLabel imageFileLabel = new JLabel();
354
327 swalkenh 355
  /** A file chooser to choose an image file. */
279 swalkenh 356
  private JFileChooser fileChooser = new JFileChooser();
357
813 swalkenh 358
  /** A button "Open..." to change images. */
359
 
521 swalkenh 360
361
  /** An image panel to show an image in. */
813 swalkenh 362
 
363
279 swalkenh 364
  /** Stores a reference to the GUI. */
813 swalkenh 365
 
366
279 swalkenh 367
  /** Stores a reference to the event listener. */
813 swalkenh 368
 
369
607 swalkenh 370
  /** The image's name from the attributes of the selected node. */
813 swalkenh 371
 
372
279 swalkenh 373
  /** The location of the image. */
813 swalkenh 374
 
375
279 swalkenh 376
  /** The current file. */
813 swalkenh 377
 
378
279 swalkenh 379
  /** The node given from the basis program. */
813 swalkenh 380
 
381
279 swalkenh 382
  /** The node returned to the basis program. */
813 swalkenh 383
 
384
279 swalkenh 385
  /** 
813 swalkenh 386
 
387
   * the necessary listeners and displays it.
348 swalkenh 388
   */
521 swalkenh 389
 
813 swalkenh 390
607 swalkenh 391
	// Sets new layout.
813 swalkenh 392
 
393
	imagePanel.addMouseListener(this);
607 swalkenh 394
	imagePanel.addMouseMotionListener(this);
813 swalkenh 395
 
396
	// Left panel: text field to enter name of image.
279 swalkenh 397
	JPanel leftPanel = new JPanel();
813 swalkenh 398
 
399
	leftPanel.add(imageNameField);
607 swalkenh 400
	leftPanel.add(confirmButton, BorderLayout.EAST);
813 swalkenh 401
 
402
	// Right panel: label to show name of image file,
607 swalkenh 403
	//              open button to change images.
279 swalkenh 404
 
813 swalkenh 405
	rightPanel.setPreferredSize(new Dimension(240, 24));
406
	rightPanel.setLayout(new BorderLayout());
407
	rightPanel.add(imageFileLabel);
408
	rightPanel.add(openFileButton, BorderLayout.EAST);
409
410
 
411
	JPanel topPanel = new JPanel();
327 swalkenh 412
	topPanel.setLayout(new BorderLayout());
413
	topPanel.add(leftPanel);
414
	topPanel.add(rightPanel, BorderLayout.EAST);
279 swalkenh 415
 
813 swalkenh 416
	add(topPanel, BorderLayout.NORTH);
327 swalkenh 417
	add(imagePanel);
418
419
	confirmButton.addActionListener(this);
607 swalkenh 420
	openFileButton.addActionListener(this);
279 swalkenh 421
 
813 swalkenh 422
	setVisible(false);
423
  }
327 swalkenh 424
425
  /**
426
   * Initializes the plugin.
427
   *
428
   * @param gui A reference to the GUI object.
279 swalkenh 429
 
813 swalkenh 430
  public void init(GuiInterface gui) {
327 swalkenh 431
	this.gui = gui;
432
  }
433
434
  /**
279 swalkenh 435
 
327 swalkenh 436
   *
437
   * @param element The element that the user has chosen.
279 swalkenh 438
 
607 swalkenh 439
   * @param elementPath The <code>TreePath</code> of the selected element in the evironment.
327 swalkenh 440
   */
279 swalkenh 441
 
327 swalkenh 442
	// TODO comment
279 swalkenh 443
  	oldNode = node;
444
 
327 swalkenh 445
  	/* Clear the status panel. */
521 swalkenh 446
	gui.getStatusInterface().setIcon(StatusInterface.ICON_NONE);
813 swalkenh 447
	gui.getStatusInterface().setMessage(null);
448
	gui.getStatusInterface().setPoint(null);
449
521 swalkenh 450
	System.out.println("ImagePlugin gets node: " + node);
327 swalkenh 451
279 swalkenh 452
	if (node == null) {
453
 
327 swalkenh 454
	}
813 swalkenh 455
456
	else {
457
		System.out.println("new node: ");
458
		System.out.print("name: " + node.getNodeName());
459
		System.out.print("; attributes: ");
327 swalkenh 460
		NamedNodeMap l = node.getAttributes();
813 swalkenh 461
		if (l != null) {
462
			for (int i = 0; i < l.getLength(); i++) {
607 swalkenh 463
				System.out.print(" \"" + l.item(i).getNodeName()
813 swalkenh 464
 
465
			}
327 swalkenh 466
		}
467
		System.out.println();
468
279 swalkenh 469
 
607 swalkenh 470
		NamedNodeMap nodeAttr = node.getAttributes();
813 swalkenh 471
 
607 swalkenh 472
		imageUrl = nodeAttr.getNamedItem("url").getNodeValue();
539 swalkenh 473
		System.out.println("imageUrl: " + imageUrl);
474
	}
813 swalkenh 475
 
539 swalkenh 476
	imageNameField.setText(imageName);
477
	loadImage(imageUrl);
607 swalkenh 478
539 swalkenh 479
	gui.setPluginPanel(this);
607 swalkenh 480
	setVisible(true);
539 swalkenh 481
  }
482
813 swalkenh 483
	/**
539 swalkenh 484
 	 * Stops the plugin by setting it invisible and clearing the status panel.
485
   	 */
486
  	public void stop() {
487
		setVisible(false);
488
 
607 swalkenh 489
		gui.getStatusInterface().setMessage(null);
490
		gui.getStatusInterface().setPoint(null);
813 swalkenh 491
  	}
492
607 swalkenh 493
	/* (non-Javadoc)
539 swalkenh 494
	 * @see src.gui.PluginInterface#setOurEventListener(src.control.OurEventListener)
813 swalkenh 495
 
327 swalkenh 496
	public void setOurEventListener(OurEventListener newListener) {
607 swalkenh 497
		ourEventListener = newListener;
279 swalkenh 498
 
521 swalkenh 499
327 swalkenh 500
	/**
279 swalkenh 501
	 * Forces the text editor plugin to return the actual status as a node, 'cause
502
 
813 swalkenh 503
	 *
504
	 * @see src.gui.PluginInterface#forceStatusReport()
505
	 */
506
	public void forceStatusReport() {
507
		
508
		
509
		changedNode = oldNode.cloneNode(true);
510
		changedNode.getAttributes().getNamedItem("url").setNodeValue(imageUrl);
511
		changedNode.getAttributes().getNamedItem("name").setNodeValue(imageName);
279 swalkenh 512
 
813 swalkenh 513
		firePluginChangedElement(oldNode, changedNode);
514
	}
515
516
	private void firePluginChangedElement(Node oldNode, Node changedNode) {
517
		OurEvent e = new OurEvent(new Object[] {oldNode, changedNode, pluginName});
518
		ourEventListener.firedOurEvent(e);
348 swalkenh 519
 
813 swalkenh 520
521
  /**
522
   *  Loads image.
523
   *
524
   *  @param fileName The file name of the image to be loaded.
525
   */
526
  private void loadImage(String fileName) {
527
 
528
 
529
	currentFile = null;
607 swalkenh 530
531
	// File name is absent: status panel - "No image".
813 swalkenh 532
	if(fileName == null) {
607 swalkenh 533
	  image = null;
813 swalkenh 534
	  gui.getStatusInterface().setIcon(StatusInterface.ICON_WARNING);
348 swalkenh 535
 
813 swalkenh 536
	}
537
	// Get the current file from the directory where the doc is.
538
	else {
539
	  try {
279 swalkenh 540
 
327 swalkenh 541
		if(fileName.startsWith(doc.getParentFile().toString())) {
813 swalkenh 542
			fileName = fileName.replaceFirst(doc.getParentFile().toString() + "/", "");
543
		}
544
		if(fileName.charAt(0) == '/')
327 swalkenh 545
		  currentFile = new File(fileName);
813 swalkenh 546
		else {
547
 
548
		}
327 swalkenh 549
279 swalkenh 550
 
813 swalkenh 551
		gui.getStatusInterface().setIcon(StatusInterface.ICON_INFORMATION);
327 swalkenh 552
		gui.getStatusInterface().setMessage("Show image from " + fileName);
553
	  }
554
	  catch(IOException ex) {
555
		gui.getLogInterface().log(
556
		  LogInterface.TYPE_ERROR, "Cannot open file " + fileName);
813 swalkenh 557
		gui.getStatusInterface().setIcon(StatusInterface.ICON_ERROR);
327 swalkenh 558
		gui.getStatusInterface().setMessage("Cannot open file " + fileName);
559
	  }
577 swalkenh 560
	}
607 swalkenh 561
	imageUrl = fileName;
562
	imageFileLabel.setText(fileName);
563
	imagePanel.setImage(image);
564
  }
327 swalkenh 565
566
  /**
607 swalkenh 567
   *  Reaction of all buttons.
327 swalkenh 568
   *
577 swalkenh 569
 
570
   */
327 swalkenh 571
  public void actionPerformed(ActionEvent e) {
572
573
	if(e.getSource() == confirmButton) {
574
575
	  if(imageName != null) {
576
577
		imageName = imageNameField.getText();
578
		forceStatusReport();
579
	  }
580
	}
813 swalkenh 581
327 swalkenh 582
	if(e.getSource() == openFileButton) {
583
279 swalkenh 584
	  fileChooser.setSelectedFile(currentFile);
585
 
327 swalkenh 586
	  if(fileChooser.showOpenDialog(gui.getMainWindow())
813 swalkenh 587
		== JFileChooser.APPROVE_OPTION) {
588
589
		loadImage(fileChooser.getSelectedFile().getPath());
327 swalkenh 590
		//imageUrl = fileChooser.getSelectedFile().getPath();
813 swalkenh 591
		/*if(imageUrl != null) {
592
 
607 swalkenh 593
		}*/
813 swalkenh 594
 
607 swalkenh 595
	}
813 swalkenh 596
 
607 swalkenh 597
598
327 swalkenh 599
	/**
600
	 * Invoked when a mouse is pressed while on a component.
279 swalkenh 601
 
327 swalkenh 602
	 * @param e A mouse event indicating that a mouse button has been pressed
813 swalkenh 603
 
327 swalkenh 604
	 * 
279 swalkenh 605
 
327 swalkenh 606
	 */
813 swalkenh 607
	public void mouseDragged(MouseEvent e) {
608
 
327 swalkenh 609
			showMouse(e.getX(), e.getY());
607 swalkenh 610
		}
813 swalkenh 611
	}
607 swalkenh 612
813 swalkenh 613
	/**
327 swalkenh 614
	 * Invoked when the mouse has been moved onto a component (with no button pressed).
615
	 *
279 swalkenh 616
	 * @param e A mouse event indicating that the cursor has been moved into a component
617
 
521 swalkenh 618
 
813 swalkenh 619
	 * @see java.awt.event.MouseMotionListener#mouseMoved
620
	 */
621
	public void mouseMoved(MouseEvent e) {
622
		if(e.getSource() == imagePanel && image != null) {
623
			showMouse(e.getX(), e.getY());
624
		}
625
	}
626
627
    /**
628
     * Shows the current position of mouse.
629
     *
630
     * @param mouseX: Position of mouse.
327 swalkenh 631
     * @param mouseY: Position of mouse.
279 swalkenh 632
 
813 swalkenh 633
    public void showMouse(int mouseX, int mouseY) {
634
635
	  int x = mouseX - imagePanel.getDx();
636
	  int y = mouseY - imagePanel.getDy();
637
638
	  if(x < 0 || y < 0 || x > imagePanel.getImageWidth()
639
	    || y > imagePanel.getImageHeight()) {
640
641
	    gui.getStatusInterface().setPoint(null);
642
	  }
643
644
	  else {
327 swalkenh 645
          int xx = (int)(x * imagePanel.getCoef());
279 swalkenh 646
 
813 swalkenh 647
648
          gui.getStatusInterface().setPoint(new Point(xx, yy));
649
	  }
650
    }
651
652
	/**
653
	 * Empty method needed to implement the <code>MouseListener</code> interface.
279 swalkenh 654
 
813 swalkenh 655
	 * @see java.awt.event.MouseListener#mouseClicked
656
	 */
279 swalkenh 657
 
813 swalkenh 658
	}
659
279 swalkenh 660
 
813 swalkenh 661
	 * Empty method needed to implement the <code>MouseListener</code> interface.
662
	 * 
279 swalkenh 663
 
813 swalkenh 664
	 */
665
	public void mousePressed(MouseEvent e) {
666
	}
279 swalkenh 667
 
813 swalkenh 668
	/**
669
     * Empty method needed to implement the <code>MouseListener</code> interface.
670
     * 
279 swalkenh 671
 
813 swalkenh 672
     */
673
	public void mouseReleased(MouseEvent e) {
674
	}
675
676
  	/**
677
   	 * Empty method needed to implement the <code>MouseListener</code> interface.
327 swalkenh 678
   	 * 
348 swalkenh 679
 
813 swalkenh 680
   	 */
681
  	public void mouseEntered(MouseEvent e) {
682
  	}
683
684
	/**
685
     * Invoked when the mouse exits a component.
686
     * 
687
 
688
     *
689
     * @param e A mouse event indicating that a component has been left.
690
     */
691
    public void mouseExited(MouseEvent e) {
692
 		if(e.getSource() == imagePanel) {
693
			gui.getStatusInterface().setPoint(null);
694
		}
695
 
696
}PK
697
ðhù.VI+ê¥
698
¥
699
0src/plugins/imagePlugin/ImagePluginTransform.xsl<!-- to-direction for pictureviewer
700
     status: problems with namespace and comments
701
     updated to given schema from 15/07/2003 
702
     Last Revision: 25/07/2003 by Sascha Walkenhorst -->
703
 
704
<xsl:output method="xml" indent="yes" />
705
706
707
<xsl:template match="node()">
708
	<xsl:if test="not(name() = ('PHOTO'))">
709
	<xsl:if test="not(name() = ('IMAGE'))">
710
		<xsl:element name="{name()}">
711
			<xsl:for-each select="attribute::*">
712
				<xsl:attribute name="{name()}">
713
					<xsl:value-of select="." />
714
				</xsl:attribute>
715
			</xsl:for-each>
521 swalkenh 716
813 swalkenh 717
 
718
 
719
 
720
					<xsl:value-of select="." />
556 swalkenh 721
				</xsl:attribute>
813 swalkenh 722
			</xsl:for-each>
539 swalkenh 723
-->
724
725
 
726
 
813 swalkenh 727
			</xsl:for-each>
728
		</xsl:element>
729
	</xsl:if></xsl:if>
730
</xsl:template>
731
732
<xsl:template match="text()">
733
	<xsl:variable name="testWhetherEmpty">
734
		<xsl:value-of select="." />
735
	</xsl:variable>
736
 
737
	<xsl:if test="normalize-space($testWhetherEmpty) != ''">
738
		<xsl:value-of select="$testWhetherEmpty" />
739
	</xsl:if>
740
</xsl:template>
741
742
<xsl:template match="PHOTO"><!-- element-plugin association -->
743
	<xsl:element name="IMAGE">
744
 
745
		<xsl:attribute name="XMLEditorSavedNameOfNode">
746
			<xsl:value-of select="'PHOTO'" />
747
		</xsl:attribute>
748
		
749
		<!-- work on attributes and childs -->
539 swalkenh 750
		<xsl:attribute name="name">
751
 
813 swalkenh 752
		</xsl:attribute>
753
		<xsl:attribute name="url">
754
			<xsl:value-of select="@uri" />
755
		</xsl:attribute>
539 swalkenh 756
 
813 swalkenh 757
			<xsl:if test="not(name(.) = ('label'))">
758
			<xsl:if test="not(name(.) = ('uri'))">
759
				<xsl:attribute name="{name(.)}">
760
					<xsl:value-of select="self::node()" />
761
 
545 swalkenh 762
			</xsl:if></xsl:if>
813 swalkenh 763
		</xsl:for-each>
764
		<xsl:for-each select="node()">
765
			<xsl:apply-templates select="." />
766
		</xsl:for-each>
767
	</xsl:element>
768
 
539 swalkenh 769
770
<xsl:template match="IMAGE"><!-- element-plugin association -->
771
	<xsl:element name="IMAGE">
772
		<!-- work on attributes and childs -->
773
		<xsl:attribute name="name">
556 swalkenh 774
			<xsl:value-of select="@label" />
539 swalkenh 775
		</xsl:attribute>
776
		<xsl:attribute name="url">
813 swalkenh 777
			<xsl:value-of select="@uri" />
778
		</xsl:attribute>
539 swalkenh 779
		<xsl:for-each select="attribute::*">
780
			<xsl:if test="not(name(.) = ('label'))">
781
			<xsl:if test="not(name(.) = ('uri'))">
782
				<xsl:attribute name="{name(.)}">
783
					<xsl:value-of select="self::node()" />
784
				</xsl:attribute>
813 swalkenh 785
			</xsl:if></xsl:if>
539 swalkenh 786
		</xsl:for-each>
787
		<xsl:for-each select="node()">
788
			<xsl:apply-templates select="." />
789
 
545 swalkenh 790
	</xsl:element>
556 swalkenh 791
</xsl:template>
792
793
794
</xsl:stylesheet>PK
795
ðhù.u5æß	ß	4src/plugins/imagePlugin/ImagePluginTransformBack.xsl<!-- back-direction for pictureviewer
796
     status: problems with namespace and comments
797
     updated to given schema from 15/07/2003 
798
     Last Revision: 25/07/2003 by Sascha Walkenhorst -->
799
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
813 swalkenh 800
<xsl:output method="xml" indent="yes" />
801
556 swalkenh 802
803
<xsl:template match="node()">
804
	<xsl:if test="not(name() = ('IMAGE'))">
805
		<xsl:element name="{name()}">
806
			<xsl:for-each select="attribute::*">
807
				<xsl:attribute name="{name()}">
813 swalkenh 808
					<xsl:value-of select="." />
556 swalkenh 809
				</xsl:attribute>
810
			</xsl:for-each>
539 swalkenh 811
		
812
 
813
 
240 swalkenh 814
			</xsl:for-each>
813 swalkenh 815
 
816
	</xsl:if>
556 swalkenh 817
</xsl:template>
813 swalkenh 818
539 swalkenh 819
<xsl:template match="text()">
820
	<xsl:variable name="testWhetherEmpty">
821
 
822
 
813 swalkenh 823
824
	<xsl:if test="normalize-space($testWhetherEmpty) != ''">
825
		<xsl:value-of select="$testWhetherEmpty" />
826
	</xsl:if>
827
</xsl:template>
828
539 swalkenh 829
<xsl:template match="IMAGE">
813 swalkenh 830
	<xsl:choose>
831
 
832
			<xsl:element name="PHOTO">
833
				<!-- work on attributes and childs -->
834
				<xsl:attribute name="label">
835
					<xsl:value-of select="@name" />
836
				</xsl:attribute>
539 swalkenh 837
				<xsl:attribute name="uri">
838
 
813 swalkenh 839
				</xsl:attribute>
840
				<xsl:for-each select="attribute::*">
841
					<xsl:if test="not(name(.) = ('name'))">
842
					<xsl:if test="not(name(.) = ('url'))">
539 swalkenh 843
 
813 swalkenh 844
						<xsl:attribute name="{name(.)}">
845
							<xsl:value-of select="self::node()" />
846
						</xsl:attribute>
539 swalkenh 847
					</xsl:if></xsl:if></xsl:if>
848
 
849
				<xsl:for-each select="node()">
813 swalkenh 850
					<xsl:apply-templates select="." />
851
				</xsl:for-each>
852
			</xsl:element>
853
		</xsl:when>
854
		
855
		<xsl:otherwise>
556 swalkenh 856
			<xsl:element name="IMAGE">
813 swalkenh 857
				<!-- work on attributes and childs -->
858
				<xsl:attribute name="label">
859
					<xsl:value-of select="@name" />
860
				</xsl:attribute>
861
				<xsl:attribute name="uri">
862
					<xsl:value-of select="@url" />
863
				</xsl:attribute>
864
				<xsl:for-each select="attribute::*">
865
					<xsl:if test="not(name(.) = ('name'))">
866
					<xsl:if test="not(name(.) = ('url'))">
867
						<xsl:attribute name="{name(.)}">
868
							<xsl:value-of select="self::node()" />
869
						</xsl:attribute>
870
					</xsl:if></xsl:if>
871
				</xsl:for-each>
872
				<xsl:for-each select="node()">
873
					<xsl:apply-templates select="." />
874
 
875
			</xsl:element>
876
		</xsl:otherwise>
877
	</xsl:choose>
878
</xsl:template>
879
880
881
</xsl:stylesheet>PK
882
883
öù.	META-INF/þÊPK
884
885
öù.·Ò+META-INF/MANIFEST.MFPK
886
887
A‰ù.JÀ(=††(^src/plugins/imagePlugin/ImagePanel.classPK
888
889
U|ø.tfǨÄÄ'*src/plugins/imagePlugin/ImagePanel.javaPK
890
891
A‰ù.ã´qª"ª")3src/plugins/imagePlugin/ImagePlugin.classPK
892
893
Cù.‰k²EÁ,Á,($;src/plugins/imagePlugin/ImagePlugin.javaPK
894
895
ðhù.VI+ê¥
896
¥
897
0+hsrc/plugins/imagePlugin/ImagePluginTransform.xslPK
539 swalkenh 898
899