4,10 → 4,10 |
* Coded by: Group 5, software practice summer 2003 |
* University of Bielefeld, Germany |
* |
* @version $Revision: 1.20 $ |
* @version $Revision: 1.21 $ |
* |
* Last modification: $Date: 2003/07/23 10:19:10 $ |
* $Id: RegionEditorPlugin.java,v 1.20 2003/07/23 10:19:10 ioklasse Exp $ |
* Last modification: $Date: 2003/07/23 11:58:09 $ |
* $Id: RegionEditorPlugin.java,v 1.21 2003/07/23 11:58:09 ioklasse Exp $ |
*/ |
|
package src.plugins.regionEditorPlugin; |
51,6 → 51,7 |
import src.control.OurEventListener; |
import src.gui.*; |
import src.plugins.PluginInterface; |
import src.parser.AdapterNode; |
|
|
/** |
58,7 → 59,7 |
* |
* @author Yulia Klassen, Viktoriya Zudova |
* |
* @version $Revision: 1.20 $ Last modification: $Date: 2003/07/23 10:19:10 $ |
* @version $Revision: 1.21 $ Last modification: $Date: 2003/07/23 11:58:09 $ |
*/ |
public class RegionEditorPlugin |
extends JPanel |
202,12 → 203,30 |
gui.getStatusInterface().setMessage(null); |
gui.getStatusInterface().setPoint(null); |
|
printTree(node, 0); |
printTree(node, 0); |
if (node != null) { |
imageName = node.getAttributes().getNamedItem("image").getNodeValue(); |
} |
imageUrl = "images/office1.jpg"; // test only !!! |
|
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); |
|
218,6 → 237,57 |
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(); |
298,6 → 368,7 |
System.out.println("================================================="); |
} |
|
|
/** |
* Stops the plugin by setting it to invisible and resetting the display of the |
* status panel. |