4,22 → 4,23 |
* Coded by: Group 5, software practice summer 2003 |
* University of Bielefeld, Germany |
* |
* @version $Revision: 1.16 $ |
* @version $Revision: 1.17 $ |
* |
* Last modification: $Date: 2003/07/20 21:39:35 $ |
* $Id: RegionEditorPlugin.java,v 1.16 2003/07/20 21:39:35 ioklasse Exp $ |
* Last modification: $Date: 2003/07/21 12:10:58 $ |
* $Id: RegionEditorPlugin.java,v 1.17 2003/07/21 12:10:58 swalkenh Exp $ |
*/ |
|
package src.plugins.regionEditorPlugin; |
|
import java.util.ArrayList; |
import java.util.List; |
import java.util.ArrayList; |
|
import java.awt.Rectangle; |
import java.awt.BorderLayout; |
import java.awt.Cursor; |
import java.awt.Dimension; |
import java.awt.Image; |
import java.awt.Cursor; |
import java.awt.Point; |
import java.awt.Rectangle; |
|
import java.awt.event.ActionEvent; |
import java.awt.event.ActionListener; |
26,14 → 27,13 |
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.JMenuItem; |
import javax.swing.JPopupMenu; |
|
import java.io.File; |
import java.io.IOException; |
|
import org.w3c.dom.NamedNodeMap; |
import org.w3c.dom.Document; |
import org.w3c.dom.Node; |
53,9 → 53,12 |
|
|
/** |
* RegionEditor plugin shows and edits regions of images. |
* The <code>RegionEditor</code> plugin shows and edits image regions. |
* |
* @author Yulia Klassen, Viktoriya Zudova |
* @author Yulia Klassen |
* @author Viktoriya Zudova |
* |
* @version $Revision: 1.45 $ Last modification: $Date: 2003/07/18 13:55:25 $ |
*/ |
public class RegionEditorPlugin |
extends JPanel |
79,7 → 82,6 |
/* Stores a reference to the GUI. */ |
private GuiInterface gui; |
|
//added 11/07/03 Sascha W.; own events are available now |
/* Stores a reference to the event listener. */ |
private OurEventListener ourEventListener; |
|
126,8 → 128,8 |
private JMenuItem deleteSelectedItem = new JMenuItem("Delete the rectangle"); |
|
/** The class constructor creates all elements for the RegionEditor plugin. */ |
public RegionEditorPlugin() |
{ |
public RegionEditorPlugin() { |
|
// Sets new layout. |
setLayout(new BorderLayout()); |
|
166,65 → 168,65 |
setVisible(false); |
} |
|
/** |
* Initializes the plugin. |
* |
* @param gui: A reference to the GUI object. |
*/ |
public void init(GuiInterface gui) |
{ |
this.gui = gui; |
} |
/** |
* 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 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) |
{ |
oldNode = node; |
gui.getStatusInterface().setIcon(StatusInterface.ICON_NONE); |
gui.getStatusInterface().setMessage(null); |
gui.getStatusInterface().setPoint(null); |
/** |
* 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); |
|
//modified 21/07/03 Sascha W. for testing |
if (node != null) { |
imageName = node.getAttributes().getNamedItem("image").getNodeValue(); |
} |
imageUrl = "images/hermann.jpg"; // test only !!! |
if (node != null) { |
imageName = node.getAttributes().getNamedItem("image").getNodeValue(); |
} |
imageUrl = "images/hermann.jpg"; // test only !!! |
|
imageNameField.setText(imageName); |
loadImage(imageUrl); |
imageNameField.setText(imageName); |
loadImage(imageUrl); |
|
gui.setPluginPanel(this); |
setVisible(true); |
} |
gui.setPluginPanel(this); |
setVisible(true); |
} |
|
/** |
* Stops the plugin. |
*/ |
public void stop() |
{ |
setVisible(false); |
gui.getStatusInterface().setIcon(StatusInterface.ICON_NONE); |
gui.getStatusInterface().setMessage(null); |
gui.getStatusInterface().setPoint(null); |
} |
/** |
* 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; |
} |
|
/* (non-Javadoc) |
* @see src.gui.PluginInterface#setOurEventListener(src.control.OurEventListener) |
*/ |
public void setOurEventListener(OurEventListener newListener) { |
ourEventListener = newListener; |
} |
|
|
//added 11/07/03 Sascha W.; own events are available now |
/** |
* 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. |
238,15 → 240,11 |
firePluginChangedElement(oldNode, changedNode); |
} |
|
|
//added 11/07/03 Sascha W.; own events are available now |
private void firePluginChangedElement(Node oldNode, Node changedNode) { |
OurEvent e = new OurEvent(new Object[] {oldNode, changedNode, pluginName}); |
ourEventListener.firedOurEvent(e); |
} |
|
//==================================================================================== |
|
/** |
* Loads image. |
* |
315,6 → 313,8 |
/** |
* Invoked when a mouse button is pressed on a component. |
* |
* @see |
* |
* @param e mouse event |
*/ |
public void mouseDragged(MouseEvent e) |
420,18 → 420,18 |
} |
} |
|
/** |
* Invoked when the mouse has been clicked on a component. |
* |
* @param e mouse event |
*/ |
public void mouseClicked(MouseEvent e) |
{ |
if(e.getSource() == imagePanel && image != null) { |
selectRect(e.getX(), e.getY()); |
repaint(); |
} |
} |
/** |
* 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) { |
selectRect(e.getX(), e.getY()); |
repaint(); |
} |
} |
|
/** |
* Invoked when a mouse button has been pressed on a Component. |
468,43 → 468,46 |
} |
} |
|
/** |
* Invoked when a mouse button has been released on a component. |
* |
* @param e mouse event |
*/ |
public void mouseReleased(MouseEvent e) |
{ |
if(e.getSource() == imagePanel && image != null) { |
if(e.isPopupTrigger()) { // Show popup. |
showPopup(e.getX(), e.getY()); |
} |
/** |
* 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; |
} |
} |
inMove = false; |
inResize = false; |
} |
} |
|
/** |
* Invoked when the mouse enters a component. |
* |
* @param e mouse event |
*/ |
public void mouseEntered(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. |
* |
* @param e mouse event |
*/ |
public void mouseExited(MouseEvent e) |
{ |
if(e.getSource() == imagePanel) { |
gui.getStatusInterface().setPoint(null); |
} |
} |
/** |
* 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); |
} |
} |
|
/** |
* ... |
608,14 → 611,13 |
popup.show(this, x, y); |
} |
|
/** |
* ... |
* |
* @param rect ... |
*/ |
private void setSelectedRect(Rectangle rect) |
{ |
selectedRect = rect; |
imagePanel.setSelectedRect(rect); |
} |
/** |
* Sets the currently selected rectangle in the image panel. |
* |
* @param rect: The rectangle selected. |
*/ |
private void setSelectedRect(Rectangle rect) { |
selectedRect = rect; |
imagePanel.setSelectedRect(rect); |
} |
} |