You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by sf...@apache.org on 2010/12/12 17:10:52 UTC

svn commit: r1044841 [1/11] - in /incubator/stanbol/trunk/fise: SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/ SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/ui/ SemiAutomaticContentEnhancer/src/main/java/eu/iks...

Author: sfermigier
Date: Sun Dec 12 16:10:48 2010
New Revision: 1044841

URL: http://svn.apache.org/viewvc?rev=1044841&view=rev
Log:
Expand tabs. Fixes.


Modified:
    incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/Sace.java
    incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/ui/SaceGUI.java
    incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/ui/SacePanelImage.java
    incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/ui/SacePanelText.java
    incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/util/DocumentAnnotation.java
    incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/util/EntityAnnotation.java
    incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/util/ImageAnnotation.java
    incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/util/TextAnnotation.java
    incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/util/Util.java
    incubator/stanbol/trunk/fise/clerezza/clerezza-sparql/src/main/java/eu/iksproject/fise/clerezza/sparql/ClerezzaSparqlQueryEngine.java
    incubator/stanbol/trunk/fise/clerezza/eu.iksproject.fise.clerezza/src/main/java/eu/iksproject/fise/clerezza/ClerezzaStore.java
    incubator/stanbol/trunk/fise/clerezza/eu.iksproject.fise.clerezza/src/main/java/eu/iksproject/fise/clerezza/FiseHandler.java
    incubator/stanbol/trunk/fise/engines/autotagging/src/main/java/eu/iksproject/fise/engines/autotagging/impl/AutotaggingServlet.java
    incubator/stanbol/trunk/fise/engines/autotagging/src/main/java/eu/iksproject/fise/engines/autotagging/impl/EnhancementRDFUtils.java
    incubator/stanbol/trunk/fise/engines/autotagging/src/main/java/eu/iksproject/fise/engines/autotagging/impl/RelatedTopicEnhancementEngine.java
    incubator/stanbol/trunk/fise/engines/entitytagging/src/main/java/eu/iksproject/fise/engines/entitytagging/impl/EnhancementRDFUtils.java
    incubator/stanbol/trunk/fise/engines/entitytagging/src/main/java/eu/iksproject/fise/engines/entitytagging/impl/ReferencedSiteEntityTaggingEnhancementEngine.java
    incubator/stanbol/trunk/fise/engines/entitytagging/src/test/java/eu/iksproject/fise/engines/entitytagging/impl/TestEntityLinkingEnhancementEngine.java
    incubator/stanbol/trunk/fise/engines/geonames/src/main/java/eu/iksproject/fise/engines/geonames/impl/LocationEnhancementEngine.java
    incubator/stanbol/trunk/fise/engines/geonames/src/test/java/eu/iksproject/fise/engines/geonames/impl/TestLocationEnhancementEngine.java
    incubator/stanbol/trunk/fise/engines/langid/src/test/java/eu/iksproject/fise/engines/langid/core/TextCatTest.java
    incubator/stanbol/trunk/fise/engines/metaxa/src/main/java/eu/iksproject/fise/engines/metaxa/core/MetaxaCore.java
    incubator/stanbol/trunk/fise/engines/metaxa/src/main/java/eu/iksproject/fise/engines/metaxa/core/html/CharsetRecognizer.java
    incubator/stanbol/trunk/fise/engines/metaxa/src/main/java/eu/iksproject/fise/engines/metaxa/core/html/DOMUtils.java
    incubator/stanbol/trunk/fise/engines/metaxa/src/main/java/eu/iksproject/fise/engines/metaxa/core/html/HtmlExtractionComponent.java
    incubator/stanbol/trunk/fise/engines/metaxa/src/main/java/eu/iksproject/fise/engines/metaxa/core/html/HtmlExtractionRegistry.java
    incubator/stanbol/trunk/fise/engines/metaxa/src/main/java/eu/iksproject/fise/engines/metaxa/core/html/HtmlExtractorFactory.java
    incubator/stanbol/trunk/fise/engines/metaxa/src/main/java/eu/iksproject/fise/engines/metaxa/core/html/HtmlParser.java
    incubator/stanbol/trunk/fise/engines/metaxa/src/main/java/eu/iksproject/fise/engines/metaxa/core/html/IksHtmlExtractor.java
    incubator/stanbol/trunk/fise/engines/metaxa/src/main/java/eu/iksproject/fise/engines/metaxa/core/html/InitializationException.java
    incubator/stanbol/trunk/fise/engines/metaxa/src/main/java/eu/iksproject/fise/engines/metaxa/core/html/XsltExtractor.java
    incubator/stanbol/trunk/fise/engines/metaxa/src/test/java/eu/iksproject/fise/engines/metaxa/core/TestMetaxaCore.java
    incubator/stanbol/trunk/fise/engines/opennlp-ner/src/main/java/eu/iksproject/fise/engines/opennlp/impl/NamedEntityExtractionEnhancementEngine.java
    incubator/stanbol/trunk/fise/engines/opennlp-ner/src/test/java/eu/iksproject/fise/engines/opennlp/impl/TestNamedEntityExtractionEnhancementEngine.java
    incubator/stanbol/trunk/fise/engines/zemanta/src/main/java/eu/iksproject/fise/engines/zemanta/impl/ZemantaAPIWrapper.java
    incubator/stanbol/trunk/fise/engines/zemanta/src/main/java/eu/iksproject/fise/engines/zemanta/impl/ZemantaPropertyEnum.java
    incubator/stanbol/trunk/fise/engines/zemanta/src/test/java/eu/iksproject/fise/engines/zemanta/impl/ZemantaEnhancementEngineTest.java
    incubator/stanbol/trunk/fise/ext/org.geonames/src/main/java/org/geonames/Address.java
    incubator/stanbol/trunk/fise/ext/org.geonames/src/main/java/org/geonames/FeatureClass.java
    incubator/stanbol/trunk/fise/ext/org.geonames/src/main/java/org/geonames/InsufficientStyleException.java
    incubator/stanbol/trunk/fise/ext/org.geonames/src/main/java/org/geonames/Intersection.java
    incubator/stanbol/trunk/fise/ext/org.geonames/src/main/java/org/geonames/InvalidParameterException.java
    incubator/stanbol/trunk/fise/ext/org.geonames/src/main/java/org/geonames/PostalCode.java
    incubator/stanbol/trunk/fise/ext/org.geonames/src/main/java/org/geonames/PostalCodeSearchCriteria.java
    incubator/stanbol/trunk/fise/ext/org.geonames/src/main/java/org/geonames/StreetSegment.java
    incubator/stanbol/trunk/fise/ext/org.geonames/src/main/java/org/geonames/Style.java
    incubator/stanbol/trunk/fise/ext/org.geonames/src/main/java/org/geonames/Timezone.java
    incubator/stanbol/trunk/fise/ext/org.geonames/src/main/java/org/geonames/Toponym.java
    incubator/stanbol/trunk/fise/ext/org.geonames/src/main/java/org/geonames/ToponymSearchCriteria.java
    incubator/stanbol/trunk/fise/ext/org.geonames/src/main/java/org/geonames/ToponymSearchResult.java
    incubator/stanbol/trunk/fise/ext/org.geonames/src/main/java/org/geonames/WebService.java
    incubator/stanbol/trunk/fise/ext/org.geonames/src/main/java/org/geonames/WikipediaArticle.java
    incubator/stanbol/trunk/fise/ext/org.geonames/src/main/java/org/geonames/utils/Bearing.java
    incubator/stanbol/trunk/fise/ext/org.geonames/src/main/java/org/geonames/utils/Distance.java
    incubator/stanbol/trunk/fise/ext/org.geonames/src/main/java/org/geonames/wikipedia/TextSummaryExtractor.java
    incubator/stanbol/trunk/fise/ext/org.geonames/src/test/java/eu/iksproject/fise/ext/org/geonames/TestScore.java
    incubator/stanbol/trunk/fise/generic/jobmanager/src/main/java/eu/iksproject/fise/jobmanager/impl/InMemoryJobManager.java
    incubator/stanbol/trunk/fise/generic/jsonld/src/main/java/eu/iksproject/fise/jsonld/JsonComparator.java
    incubator/stanbol/trunk/fise/generic/jsonld/src/main/java/eu/iksproject/fise/jsonld/JsonLd.java
    incubator/stanbol/trunk/fise/generic/jsonld/src/main/java/eu/iksproject/fise/jsonld/JsonLdResource.java
    incubator/stanbol/trunk/fise/generic/jsonld/src/main/java/eu/iksproject/fise/jsonld/JsonSerializer.java
    incubator/stanbol/trunk/fise/generic/jsonld/src/test/java/eu/iksproject/fise/jsonld/JsonLdTest.java
    incubator/stanbol/trunk/fise/generic/servicesapi/src/main/java/eu/iksproject/fise/servicesapi/ContentItem.java
    incubator/stanbol/trunk/fise/generic/servicesapi/src/main/java/eu/iksproject/fise/servicesapi/Enhancement.java
    incubator/stanbol/trunk/fise/generic/servicesapi/src/main/java/eu/iksproject/fise/servicesapi/EnhancementEngine.java
    incubator/stanbol/trunk/fise/generic/servicesapi/src/main/java/eu/iksproject/fise/servicesapi/EntityAnnotation.java
    incubator/stanbol/trunk/fise/generic/servicesapi/src/main/java/eu/iksproject/fise/servicesapi/ServiceProperties.java
    incubator/stanbol/trunk/fise/generic/servicesapi/src/main/java/eu/iksproject/fise/servicesapi/SparqlQueryEngine.java
    incubator/stanbol/trunk/fise/generic/servicesapi/src/main/java/eu/iksproject/fise/servicesapi/Store.java
    incubator/stanbol/trunk/fise/generic/servicesapi/src/main/java/eu/iksproject/fise/servicesapi/TextAnnotation.java
    incubator/stanbol/trunk/fise/generic/servicesapi/src/main/java/eu/iksproject/fise/servicesapi/helper/EnhancementEngineHelper.java
    incubator/stanbol/trunk/fise/generic/servicesapi/src/main/java/eu/iksproject/fise/servicesapi/helper/Rdf.java
    incubator/stanbol/trunk/fise/generic/servicesapi/src/main/java/eu/iksproject/fise/servicesapi/helper/RdfEntity.java
    incubator/stanbol/trunk/fise/generic/servicesapi/src/main/java/eu/iksproject/fise/servicesapi/helper/RdfEntityFactory.java
    incubator/stanbol/trunk/fise/generic/servicesapi/src/main/java/eu/iksproject/fise/servicesapi/helper/impl/RdfProxyInvocationHandler.java
    incubator/stanbol/trunk/fise/generic/servicesapi/src/main/java/eu/iksproject/fise/servicesapi/helper/impl/SimpleRdfEntityFactory.java
    incubator/stanbol/trunk/fise/generic/servicesapi/src/main/java/eu/iksproject/fise/servicesapi/rdf/OntologicalClasses.java
    incubator/stanbol/trunk/fise/generic/servicesapi/src/main/java/eu/iksproject/fise/servicesapi/rdf/Properties.java
    incubator/stanbol/trunk/fise/generic/servicesapi/src/main/java/eu/iksproject/fise/servicesapi/rdf/TechnicalClasses.java
    incubator/stanbol/trunk/fise/generic/servicesapi/src/test/java/eu/iksproject/fise/serviceapi/helper/EnhancementEngineHelperTest.java
    incubator/stanbol/trunk/fise/generic/servicesapi/src/test/java/eu/iksproject/fise/serviceapi/helper/RdfEntityFactoryTest.java
    incubator/stanbol/trunk/fise/generic/servicesapi/src/test/java/eu/iksproject/fise/serviceapi/helper/TestEnhancementInterfaces.java
    incubator/stanbol/trunk/fise/generic/standalone/src/main/java/eu/iksproject/fise/standalone/impl/MainServlet.java
    incubator/stanbol/trunk/fise/iks-autotagging/src/main/java/eu/iksproject/autotagging/Autotagger.java
    incubator/stanbol/trunk/fise/iks-autotagging/src/main/java/eu/iksproject/autotagging/TagInfo.java
    incubator/stanbol/trunk/fise/integration-tests/src/test/java/org/apache/stanbol/commons/testing/it/JarExecutor.java
    incubator/stanbol/trunk/fise/integration-tests/src/test/java/org/apache/stanbol/enhancer/it/DummyTest.java
    incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/JerseyEndpoint.java
    incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/JettyServer.java
    incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/processors/FreemarkerViewProcessor.java
    incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/writers/GraphWriter.java
    incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/writers/JsonLdSerializerProvider.java
    incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/writers/ResultSetToXml.java
    incubator/stanbol/trunk/fise/jersey/src/main/java/eu/iksproject/fise/jersey/writers/ResultSetWriter.java
    incubator/stanbol/trunk/fise/jersey/src/test/java/eu/iksproject/fise/jersey/JettyServerTest.java
    incubator/stanbol/trunk/fise/jersey/src/test/java/eu/iksproject/fise/jersey/writers/JsonLdSerializerProviderTest.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/QueryManager.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/Start.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/ClerezzaResultEvent.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/ClerezzaServerInfoChangedEvent.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/Event.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/EventListener.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/EventManager.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/NotUnderstoodEvent.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/PlaybackAudioEvent.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/QueryEvent.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/RecognizedSpeechEvent.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/RecordedAudioEvent.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/SparqlEvent.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/TtsEvent.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/event/UploadFileEvent.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/gui/ConfigurationPanel.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/gui/Gui.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/gui/ResultPanel.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/gui/UploadPanel.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/speech/Asr.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/speech/NL2Sparql.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/speech/Playback.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/speech/PlaybackInProgressException.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/speech/Recording.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/speech/RecordingInProgressException.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/speech/SpeechServer.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/speech/Tts.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/util/Base64.java
    incubator/stanbol/trunk/fise/query-rendering/src/eu/iksproject/fise/interaction/util/ClientHttpRequest.java
    incubator/stanbol/trunk/fise/stores/jcrstore/src/main/java/eu/iksproject/fise/store/JCRStore.java
    incubator/stanbol/trunk/fise/stores/jcrstore/src/main/java/eu/iksproject/fise/store/jcr/JCRContentItem.java

Modified: incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/Sace.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/Sace.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/Sace.java (original)
+++ incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/Sace.java Sun Dec 12 16:10:48 2010
@@ -24,266 +24,266 @@ import eu.iksproject.fise.sace.util.Util
 
 public class Sace {
 
-	private String serverUrl;
-	private SaceGUI gui;
-	public static final String DEFAULT_URL = "http://localhost:8080/engines";
-	public static final String WINDOW_TITLE = "FISE - S.A.C.E";
-
-	public Sace() {
-		try {
-			this.serverUrl = getServerUrl();
-			this.gui = new SaceGUI(this, WINDOW_TITLE + " (" + serverUrl + ")");
-		} catch (IllegalStateException ise) {
-			// user entered wrong or missing url -> shutdown
-			System.err.println(ise.getMessage());
-			System.exit(1);
-		}
-	}
-
-	static String getServerUrl() {
-		final String result = (String) JOptionPane.showInputDialog(null,
-				"Please indicate the FISE server URL", WINDOW_TITLE,
-				JOptionPane.PLAIN_MESSAGE, null, null, DEFAULT_URL);
-
-		if (result == null || result.trim().length() == 0) {
-			throw new IllegalStateException("Missing server URL");
-		}
-		return result.trim();
-	}
-
-	public List<IAnnotation> annotateTextWithFISE(final String text) {
-		// get stuff from FISE
-		String result = sendTextToFISE(text);
-		System.out.println(result);
-		// transform FISE-annotations to SACE-annotations
-		return transformRDFXMLToAnnotations(result);
-
-	}
-
-	public String sendTextToFISE(String text) {
-		try {
-
-			// Construct data
-			String data = URLEncoder.encode("format", "UTF-8") + "="
-					+ URLEncoder.encode("application/rdf+xml", "UTF-8");
-			data += "&" + URLEncoder.encode("content", "UTF-8") + "="
-					+ URLEncoder.encode(text, "UTF-8");
-			// Send data
-			URL url = new URL(serverUrl);
-			URLConnection conn = url.openConnection();
-			conn.setDoOutput(true);
-			OutputStreamWriter wr = new OutputStreamWriter(conn
-					.getOutputStream());
-			wr.write(data);
-			wr.flush();
-
-			// Get the response
-			String resultText = "";
-			BufferedReader rd = new BufferedReader(new InputStreamReader(conn
-					.getInputStream()));
-			String line;
-			while ((line = rd.readLine()) != null) {
-				// Process line...
-				resultText += (line + "\n");
-			}
-			wr.close();
-			rd.close();
-			return resultText;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
-
-	private List<IAnnotation> transformRDFXMLToAnnotations(String rdfXml) {
-		List<IAnnotation> retVal = new LinkedList<IAnnotation>();
-		Document doc = Util.transformToXML(rdfXml);
-
-		List<TextAnnotation> textAnnotations = new LinkedList<TextAnnotation>();
-		List<DocumentAnnotation> documentAnnotations = new LinkedList<DocumentAnnotation>();
-		List<EntityAnnotation> entityAnnotations = new LinkedList<EntityAnnotation>();
-
-		for (Object o1 : doc.getRootElement().getChildren()) {
-			Element node = (Element) o1;
-
-			boolean isDocumentAnnotation = false;
-			boolean isTextAnnotation = false;
-			boolean isEntityAnnotation = false;
-			for (Object o2 : node.getChildren()) {
-				Element subject = (Element) o2;
-
-				String name = subject.getName();
-				String ns = subject.getNamespace().getURI();
-
-				isDocumentAnnotation |= name.equals("doc-lang")
-						&& ns.equals("http://iksproject.eu/ns/extraction/");
-				isTextAnnotation |= name.equals("type")
-						&& ns
-								.equals("http://www.w3.org/1999/02/22-rdf-syntax-ns#")
-						&& subject.getAttribute("resource",
-								subject.getNamespace()).getValue().endsWith(
-								"TextAnnotation");
-				isEntityAnnotation |= name.equals("type")
-						&& ns
-								.equals("http://www.w3.org/1999/02/22-rdf-syntax-ns#")
-						&& subject.getAttribute("resource",
-								subject.getNamespace()).getValue().endsWith(
-								"EntityAnnotation");
-			}
-
-			if (isDocumentAnnotation) {
-				DocumentAnnotation docAnnot = new DocumentAnnotation();
-				String name = node.getAttribute("about", node.getNamespace())
-						.getValue();
-				docAnnot.setName(name);
-				for (Object o2 : node.getChildren()) {
-					Element subject = (Element) o2;
-
-					if (subject.getName().equals("doc-lang")
-							&& subject.getNamespace().getURI().equals(
-									"http://iksproject.eu/ns/extraction/")) {
-						docAnnot.addAttribute("lang", subject.getText());
-					}
-					// TODO: fill with other stuff once available
-
-				}
-				documentAnnotations.add(docAnnot);
-			} else if (isTextAnnotation) {
-				TextAnnotation textAnnot = new TextAnnotation();
-				String name = node.getAttribute("about", node.getNamespace())
-						.getValue();
-				textAnnot.setName(name);
-
-				for (Object o2 : node.getChildren()) {
-					Element subject = (Element) o2;
-
-					String sName = subject.getName();
-					String sNs = subject.getNamespaceURI();
-
-					if (sName.equals("creator")
-							&& sNs.equals("http://purl.org/dc/terms/")) {
-						String creator = subject.getText();
-						textAnnot.setCreator(creator);
-					} else if (sName.equals("created")
-							&& sNs.equals("http://purl.org/dc/terms/")) {
-						String created = subject.getText();
-						textAnnot.setCreated(created);
-					} else if (sName.equals("selection-context")
-							&& sNs
-									.equals("http://fise.iks-project.eu/ontology/")) {
-						String selectionContext = subject.getText();
-						textAnnot.setSelectionContext(selectionContext);
-					} else if (sName.equals("selected-text")
-							&& sNs
-									.equals("http://fise.iks-project.eu/ontology/")) {
-						String selectedText = subject.getText();
-						textAnnot.setSelectedText(selectedText);
-					} else if (sName.equals("type")
-							&& sNs.equals("http://purl.org/dc/terms/")) {
-						String type = subject.getAttribute("resource",
-								node.getNamespace()).getValue();
-						textAnnot.addAttribute("type", type);
-					} else if (sName.equals("start")
-							&& sNs
-									.equals("http://fise.iks-project.eu/ontology/")) {
-						int index = Integer.parseInt(subject.getText());
-						textAnnot.setStartIndex(index);
-					} else if (sName.equals("end")
-							&& sNs
-									.equals("http://fise.iks-project.eu/ontology/")) {
-						int index = Integer.parseInt(subject.getText());
-						textAnnot.setEndIndex(index);
-					}
-
-					// TODO: once they are available
-					double confidence = 0.0;
-				}
-				textAnnotations.add(textAnnot);
-			} else if (isEntityAnnotation) {
-				EntityAnnotation entityAnnot = new EntityAnnotation();
-				String name = node.getAttribute("about", node.getNamespace())
-						.getValue();
-				entityAnnot.setName(name);
-
-				for (Object o2 : node.getChildren()) {
-					Element subject = (Element) o2;
-
-					String sName = subject.getName();
-					String sNs = subject.getNamespaceURI();
-
-					if (sName.equals("creator")
-							&& sNs.equals("http://purl.org/dc/terms/")) {
-						String creator = subject.getText();
-						entityAnnot.setCreator(creator);
-					} else if (sName.equals("created")
-							&& sNs.equals("http://purl.org/dc/terms/")) {
-						String created = subject.getText();
-						entityAnnot.setCreated(created);
-					} else if (sName.equals("entity-type")
-							&& sNs
-									.equals("http://fise.iks-project.eu/ontology/")) {
-						String entityType = subject.getAttribute("resource",
-								node.getNamespace()).getValue();
-						entityAnnot.addAttribute("entity-type", entityType);
-					} else if (sName.equals("entity-reference")
-							&& sNs
-									.equals("http://fise.iks-project.eu/ontology/")) {
-						String entityRef = subject.getAttribute("resource",
-								node.getNamespace()).getValue();
-						entityAnnot.addAttribute("entity-reference", entityRef);
-					} else if (sName.equals("entity-label")
-							&& sNs
-									.equals("http://fise.iks-project.eu/ontology/")) {
-						String entityLabel = subject.getText();
-						entityAnnot.addAttribute("entity-label", entityLabel);
-					} else if (sName.equals("relation")
-							&& sNs.equals("http://purl.org/dc/terms/")) {
-						String relation = subject.getAttribute("resource",
-								node.getNamespace()).getValue();
-						entityAnnot.setRelation(relation);
-					}
-
-					// TODO: once they are available
-					double confidence = 0.0;
-				}
-				entityAnnotations.add(entityAnnot);
-			}
-		}
-
-		for (TextAnnotation ta : textAnnotations) {
-			String taName = ta.getName();
-			for (EntityAnnotation ea : entityAnnotations) {
-				if (ea.getRelation().equals(taName)) {
-					ta.addEntityAnnotation(ea);
-				}
-			}
-			retVal.add(ta);
-		}
-		for (DocumentAnnotation da : documentAnnotations) {
-			retVal.add(da);
-		}
-
-		return retVal;
-	}
-
-	public void submitTextAnnotationToFISE(TextAnnotation ta) {
-		// TODO!
-	}
-
-	public void submitEntityAnnotationToFISE(EntityAnnotation ea) {
-		// TODO!
-	}
-
-	public void submitDocumentAnnotationToFISE(DocumentAnnotation da) {
-		// TODO!
-	}
-
-	public void submitImageAnnotationToFISE(ImageAnnotation ia) {
-		// TODO!
-	}
-
-	public static void main(String[] args) {
-		new Sace();
-	}
+    private String serverUrl;
+    private SaceGUI gui;
+    public static final String DEFAULT_URL = "http://localhost:8080/engines";
+    public static final String WINDOW_TITLE = "FISE - S.A.C.E";
+
+    public Sace() {
+        try {
+            this.serverUrl = getServerUrl();
+            this.gui = new SaceGUI(this, WINDOW_TITLE + " (" + serverUrl + ")");
+        } catch (IllegalStateException ise) {
+            // user entered wrong or missing url -> shutdown
+            System.err.println(ise.getMessage());
+            System.exit(1);
+        }
+    }
+
+    static String getServerUrl() {
+        final String result = (String) JOptionPane.showInputDialog(null,
+                "Please indicate the FISE server URL", WINDOW_TITLE,
+                JOptionPane.PLAIN_MESSAGE, null, null, DEFAULT_URL);
+
+        if (result == null || result.trim().length() == 0) {
+            throw new IllegalStateException("Missing server URL");
+        }
+        return result.trim();
+    }
+
+    public List<IAnnotation> annotateTextWithFISE(final String text) {
+        // get stuff from FISE
+        String result = sendTextToFISE(text);
+        System.out.println(result);
+        // transform FISE-annotations to SACE-annotations
+        return transformRDFXMLToAnnotations(result);
+
+    }
+
+    public String sendTextToFISE(String text) {
+        try {
+
+            // Construct data
+            String data = URLEncoder.encode("format", "UTF-8") + "="
+                    + URLEncoder.encode("application/rdf+xml", "UTF-8");
+            data += "&" + URLEncoder.encode("content", "UTF-8") + "="
+                    + URLEncoder.encode(text, "UTF-8");
+            // Send data
+            URL url = new URL(serverUrl);
+            URLConnection conn = url.openConnection();
+            conn.setDoOutput(true);
+            OutputStreamWriter wr = new OutputStreamWriter(conn
+                    .getOutputStream());
+            wr.write(data);
+            wr.flush();
+
+            // Get the response
+            String resultText = "";
+            BufferedReader rd = new BufferedReader(new InputStreamReader(conn
+                    .getInputStream()));
+            String line;
+            while ((line = rd.readLine()) != null) {
+                // Process line...
+                resultText += (line + "\n");
+            }
+            wr.close();
+            rd.close();
+            return resultText;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    private List<IAnnotation> transformRDFXMLToAnnotations(String rdfXml) {
+        List<IAnnotation> retVal = new LinkedList<IAnnotation>();
+        Document doc = Util.transformToXML(rdfXml);
+
+        List<TextAnnotation> textAnnotations = new LinkedList<TextAnnotation>();
+        List<DocumentAnnotation> documentAnnotations = new LinkedList<DocumentAnnotation>();
+        List<EntityAnnotation> entityAnnotations = new LinkedList<EntityAnnotation>();
+
+        for (Object o1 : doc.getRootElement().getChildren()) {
+            Element node = (Element) o1;
+
+            boolean isDocumentAnnotation = false;
+            boolean isTextAnnotation = false;
+            boolean isEntityAnnotation = false;
+            for (Object o2 : node.getChildren()) {
+                Element subject = (Element) o2;
+
+                String name = subject.getName();
+                String ns = subject.getNamespace().getURI();
+
+                isDocumentAnnotation |= name.equals("doc-lang")
+                        && ns.equals("http://iksproject.eu/ns/extraction/");
+                isTextAnnotation |= name.equals("type")
+                        && ns
+                                .equals("http://www.w3.org/1999/02/22-rdf-syntax-ns#")
+                        && subject.getAttribute("resource",
+                                subject.getNamespace()).getValue().endsWith(
+                                "TextAnnotation");
+                isEntityAnnotation |= name.equals("type")
+                        && ns
+                                .equals("http://www.w3.org/1999/02/22-rdf-syntax-ns#")
+                        && subject.getAttribute("resource",
+                                subject.getNamespace()).getValue().endsWith(
+                                "EntityAnnotation");
+            }
+
+            if (isDocumentAnnotation) {
+                DocumentAnnotation docAnnot = new DocumentAnnotation();
+                String name = node.getAttribute("about", node.getNamespace())
+                        .getValue();
+                docAnnot.setName(name);
+                for (Object o2 : node.getChildren()) {
+                    Element subject = (Element) o2;
+
+                    if (subject.getName().equals("doc-lang")
+                            && subject.getNamespace().getURI().equals(
+                                    "http://iksproject.eu/ns/extraction/")) {
+                        docAnnot.addAttribute("lang", subject.getText());
+                    }
+                    // TODO: fill with other stuff once available
+
+                }
+                documentAnnotations.add(docAnnot);
+            } else if (isTextAnnotation) {
+                TextAnnotation textAnnot = new TextAnnotation();
+                String name = node.getAttribute("about", node.getNamespace())
+                        .getValue();
+                textAnnot.setName(name);
+
+                for (Object o2 : node.getChildren()) {
+                    Element subject = (Element) o2;
+
+                    String sName = subject.getName();
+                    String sNs = subject.getNamespaceURI();
+
+                    if (sName.equals("creator")
+                            && sNs.equals("http://purl.org/dc/terms/")) {
+                        String creator = subject.getText();
+                        textAnnot.setCreator(creator);
+                    } else if (sName.equals("created")
+                            && sNs.equals("http://purl.org/dc/terms/")) {
+                        String created = subject.getText();
+                        textAnnot.setCreated(created);
+                    } else if (sName.equals("selection-context")
+                            && sNs
+                                    .equals("http://fise.iks-project.eu/ontology/")) {
+                        String selectionContext = subject.getText();
+                        textAnnot.setSelectionContext(selectionContext);
+                    } else if (sName.equals("selected-text")
+                            && sNs
+                                    .equals("http://fise.iks-project.eu/ontology/")) {
+                        String selectedText = subject.getText();
+                        textAnnot.setSelectedText(selectedText);
+                    } else if (sName.equals("type")
+                            && sNs.equals("http://purl.org/dc/terms/")) {
+                        String type = subject.getAttribute("resource",
+                                node.getNamespace()).getValue();
+                        textAnnot.addAttribute("type", type);
+                    } else if (sName.equals("start")
+                            && sNs
+                                    .equals("http://fise.iks-project.eu/ontology/")) {
+                        int index = Integer.parseInt(subject.getText());
+                        textAnnot.setStartIndex(index);
+                    } else if (sName.equals("end")
+                            && sNs
+                                    .equals("http://fise.iks-project.eu/ontology/")) {
+                        int index = Integer.parseInt(subject.getText());
+                        textAnnot.setEndIndex(index);
+                    }
+
+                    // TODO: once they are available
+                    double confidence = 0.0;
+                }
+                textAnnotations.add(textAnnot);
+            } else if (isEntityAnnotation) {
+                EntityAnnotation entityAnnot = new EntityAnnotation();
+                String name = node.getAttribute("about", node.getNamespace())
+                        .getValue();
+                entityAnnot.setName(name);
+
+                for (Object o2 : node.getChildren()) {
+                    Element subject = (Element) o2;
+
+                    String sName = subject.getName();
+                    String sNs = subject.getNamespaceURI();
+
+                    if (sName.equals("creator")
+                            && sNs.equals("http://purl.org/dc/terms/")) {
+                        String creator = subject.getText();
+                        entityAnnot.setCreator(creator);
+                    } else if (sName.equals("created")
+                            && sNs.equals("http://purl.org/dc/terms/")) {
+                        String created = subject.getText();
+                        entityAnnot.setCreated(created);
+                    } else if (sName.equals("entity-type")
+                            && sNs
+                                    .equals("http://fise.iks-project.eu/ontology/")) {
+                        String entityType = subject.getAttribute("resource",
+                                node.getNamespace()).getValue();
+                        entityAnnot.addAttribute("entity-type", entityType);
+                    } else if (sName.equals("entity-reference")
+                            && sNs
+                                    .equals("http://fise.iks-project.eu/ontology/")) {
+                        String entityRef = subject.getAttribute("resource",
+                                node.getNamespace()).getValue();
+                        entityAnnot.addAttribute("entity-reference", entityRef);
+                    } else if (sName.equals("entity-label")
+                            && sNs
+                                    .equals("http://fise.iks-project.eu/ontology/")) {
+                        String entityLabel = subject.getText();
+                        entityAnnot.addAttribute("entity-label", entityLabel);
+                    } else if (sName.equals("relation")
+                            && sNs.equals("http://purl.org/dc/terms/")) {
+                        String relation = subject.getAttribute("resource",
+                                node.getNamespace()).getValue();
+                        entityAnnot.setRelation(relation);
+                    }
+
+                    // TODO: once they are available
+                    double confidence = 0.0;
+                }
+                entityAnnotations.add(entityAnnot);
+            }
+        }
+
+        for (TextAnnotation ta : textAnnotations) {
+            String taName = ta.getName();
+            for (EntityAnnotation ea : entityAnnotations) {
+                if (ea.getRelation().equals(taName)) {
+                    ta.addEntityAnnotation(ea);
+                }
+            }
+            retVal.add(ta);
+        }
+        for (DocumentAnnotation da : documentAnnotations) {
+            retVal.add(da);
+        }
+
+        return retVal;
+    }
+
+    public void submitTextAnnotationToFISE(TextAnnotation ta) {
+        // TODO!
+    }
+
+    public void submitEntityAnnotationToFISE(EntityAnnotation ea) {
+        // TODO!
+    }
+
+    public void submitDocumentAnnotationToFISE(DocumentAnnotation da) {
+        // TODO!
+    }
+
+    public void submitImageAnnotationToFISE(ImageAnnotation ia) {
+        // TODO!
+    }
+
+    public static void main(String[] args) {
+        new Sace();
+    }
 
 }

Modified: incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/ui/SaceGUI.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/ui/SaceGUI.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/ui/SaceGUI.java (original)
+++ incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/ui/SaceGUI.java Sun Dec 12 16:10:48 2010
@@ -21,136 +21,136 @@ import eu.iksproject.fise.sace.util.Text
 
 public class SaceGUI extends JFrame {
 
-	private static final long serialVersionUID = -1599015661183868734L;
+    private static final long serialVersionUID = -1599015661183868734L;
 
-	private Sace sace;
+    private Sace sace;
 
-	private JButton newButton;
-	private JButton annotateContentButton;
+    private JButton newButton;
+    private JButton annotateContentButton;
 
-	private SacePanelText sacePaneltxt;
-	private SacePanelImage sacePanelimg;
-
-	public SaceGUI(Sace sace, String windowTitle) {
-		super(windowTitle);
-
-		this.sace = sace;
-
-		init();
-	}
-
-	private void init() {
-		setSize(700, 400);
-		setLocationRelativeTo(null);
-
-		sacePaneltxt = new SacePanelText(this);
-		sacePanelimg = new SacePanelImage(this);
-
-		newButton = new JButton("Create new content");
-		newButton.addActionListener(new ActionListener() {
-
-			public void actionPerformed(ActionEvent e) {
-				annotateContentButton.setEnabled(true);
-				sacePaneltxt.clear();
-				sacePanelimg.clear();
-			}
-
-		});
-
-		annotateContentButton = new JButton("Send content to FISE");
-		annotateContentButton.addActionListener(new ActionListener() {
-
-			public void actionPerformed(ActionEvent e) {
-				final String text = sacePaneltxt.getText();
-				annotateContentButton.setEnabled(false);
-
-				annotateTextWithFISE(text);
-			}
-
-		});
-
-		JPanel sace = new JPanel();
-
-		sace.setLayout(new GridLayout(1, 2));
-
-		sace.add(sacePaneltxt);
-		sace.add(sacePanelimg);
-
-		getContentPane().add(BorderLayout.NORTH, newButton);
-		getContentPane().add(BorderLayout.CENTER, sace);
-		getContentPane().add(BorderLayout.SOUTH, annotateContentButton);
-
-		setVisible(true);
-	}
-
-	public void annotateTextWithFISE(final String text) {
-		Runnable runner = new Runnable() {
-			public void run() {
-
-				List<IAnnotation> result = sace.annotateTextWithFISE(text);
-				// add the annotations to SACE
-				for (IAnnotation annot : result) {
-					if (annot instanceof DocumentAnnotation) {
-						sacePaneltxt
-								.addDocumentAnnotation((DocumentAnnotation) annot);
-					} else if (annot instanceof TextAnnotation) {
-						sacePaneltxt.addTextAnnotation((TextAnnotation) annot);
-					}
-				}
-				sacePaneltxt.finalizeText();
-			}
-		};
-		ExecutorService es = Executors.newSingleThreadExecutor();
-		es.execute(runner);
-	}
-
-	public void submitTextAnnotationToFISE(TextAnnotation annotation) {
-		Runnable runner = new Runnable() {
-			public void run() {
-				// TODO
-				System.err
-						.println("TODO: user wants to send text annotations to FISE!");
-			}
-		};
-		ExecutorService es = Executors.newSingleThreadExecutor();
-		es.execute(runner);
-	}
-
-	public void submitDocumentAnnotationToFISE(DocumentAnnotation annotation) {
-		Runnable runner = new Runnable() {
-			public void run() {
-				// TODO
-				System.err
-						.println("TODO: user wants to send document annotations to FISE!");
-			}
-		};
-		ExecutorService es = Executors.newSingleThreadExecutor();
-		es.execute(runner);
-	}
-
-	public void submitEntityAnnotationToFISE(EntityAnnotation annotation) {
-		Runnable runner = new Runnable() {
-			public void run() {
-				// TODO
-				System.err
-						.println("TODO: user wants to send entity annotations to FISE!");
-			}
-		};
-		ExecutorService es = Executors.newSingleThreadExecutor();
-		es.execute(runner);
-	}
-
-	public void submitImageAnnotationToFISE(ImageAnnotation annotation) {
-		Runnable runner = new Runnable() {
-			public void run() {
-				// TODO
-				System.err
-						.println("TODO: user wants to send image annotations to FISE!");
-			}
-		};
-		ExecutorService es = Executors.newSingleThreadExecutor();
-		es.execute(runner);
+    private SacePanelText sacePaneltxt;
+    private SacePanelImage sacePanelimg;
+
+    public SaceGUI(Sace sace, String windowTitle) {
+        super(windowTitle);
+
+        this.sace = sace;
+
+        init();
+    }
+
+    private void init() {
+        setSize(700, 400);
+        setLocationRelativeTo(null);
+
+        sacePaneltxt = new SacePanelText(this);
+        sacePanelimg = new SacePanelImage(this);
+
+        newButton = new JButton("Create new content");
+        newButton.addActionListener(new ActionListener() {
+
+            public void actionPerformed(ActionEvent e) {
+                annotateContentButton.setEnabled(true);
+                sacePaneltxt.clear();
+                sacePanelimg.clear();
+            }
+
+        });
+
+        annotateContentButton = new JButton("Send content to FISE");
+        annotateContentButton.addActionListener(new ActionListener() {
+
+            public void actionPerformed(ActionEvent e) {
+                final String text = sacePaneltxt.getText();
+                annotateContentButton.setEnabled(false);
+
+                annotateTextWithFISE(text);
+            }
+
+        });
+
+        JPanel sace = new JPanel();
+
+        sace.setLayout(new GridLayout(1, 2));
+
+        sace.add(sacePaneltxt);
+        sace.add(sacePanelimg);
+
+        getContentPane().add(BorderLayout.NORTH, newButton);
+        getContentPane().add(BorderLayout.CENTER, sace);
+        getContentPane().add(BorderLayout.SOUTH, annotateContentButton);
+
+        setVisible(true);
+    }
+
+    public void annotateTextWithFISE(final String text) {
+        Runnable runner = new Runnable() {
+            public void run() {
+
+                List<IAnnotation> result = sace.annotateTextWithFISE(text);
+                // add the annotations to SACE
+                for (IAnnotation annot : result) {
+                    if (annot instanceof DocumentAnnotation) {
+                        sacePaneltxt
+                                .addDocumentAnnotation((DocumentAnnotation) annot);
+                    } else if (annot instanceof TextAnnotation) {
+                        sacePaneltxt.addTextAnnotation((TextAnnotation) annot);
+                    }
+                }
+                sacePaneltxt.finalizeText();
+            }
+        };
+        ExecutorService es = Executors.newSingleThreadExecutor();
+        es.execute(runner);
+    }
+
+    public void submitTextAnnotationToFISE(TextAnnotation annotation) {
+        Runnable runner = new Runnable() {
+            public void run() {
+                // TODO
+                System.err
+                        .println("TODO: user wants to send text annotations to FISE!");
+            }
+        };
+        ExecutorService es = Executors.newSingleThreadExecutor();
+        es.execute(runner);
+    }
+
+    public void submitDocumentAnnotationToFISE(DocumentAnnotation annotation) {
+        Runnable runner = new Runnable() {
+            public void run() {
+                // TODO
+                System.err
+                        .println("TODO: user wants to send document annotations to FISE!");
+            }
+        };
+        ExecutorService es = Executors.newSingleThreadExecutor();
+        es.execute(runner);
+    }
+
+    public void submitEntityAnnotationToFISE(EntityAnnotation annotation) {
+        Runnable runner = new Runnable() {
+            public void run() {
+                // TODO
+                System.err
+                        .println("TODO: user wants to send entity annotations to FISE!");
+            }
+        };
+        ExecutorService es = Executors.newSingleThreadExecutor();
+        es.execute(runner);
+    }
+
+    public void submitImageAnnotationToFISE(ImageAnnotation annotation) {
+        Runnable runner = new Runnable() {
+            public void run() {
+                // TODO
+                System.err
+                        .println("TODO: user wants to send image annotations to FISE!");
+            }
+        };
+        ExecutorService es = Executors.newSingleThreadExecutor();
+        es.execute(runner);
 
-	}
+    }
 
 }

Modified: incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/ui/SacePanelImage.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/ui/SacePanelImage.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/ui/SacePanelImage.java (original)
+++ incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/ui/SacePanelImage.java Sun Dec 12 16:10:48 2010
@@ -33,283 +33,283 @@ import eu.iksproject.fise.sace.util.Text
 
 public class SacePanelImage extends JPanel {
 
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = -7607274145586243340L;
-
-	private SaceGUI saceGUI;
-
-	private Image image;
-	private String imageFilename;
-	private JLabel img;
-
-	private Rectangle currentRect = null;
-	private List<Rectangle> regions;
-
-	public SacePanelImage(SaceGUI gui) {
-		super();
-		saceGUI = gui;
-
-		init();
-
-	}
-
-	public void clear() {
-		imageFilename = "";
-		img.setText("<drop image here>");
-		img.setIcon(null);
-	}
-
-	private Rectangle translateRect(Rectangle r) {
-		Rectangle newRect = new Rectangle();
-		if (r != null) {
-			if (r.width < 0) {
-				newRect.x = r.x + r.width;
-				newRect.width = -r.width;
-			} else {
-				newRect.x = r.x;
-				newRect.width = r.width;
-			}
-			if (r.height < 0) {
-				newRect.y = r.y + r.height;
-				newRect.height = -r.height;
-			} else {
-				newRect.y = r.y;
-				newRect.height = r.height;
-			}
-			return newRect;
-		}
-		return r;
-	}
-
-	private void init() {
-		currentRect = null;
-		this.regions = new LinkedList<Rectangle>();
-		img = new JLabel("<drop image here>") {
-			/**
-			 * 
-			 */
-			private static final long serialVersionUID = 9085980562151354916L;
-
-			@Override
-			public void paint(Graphics g) {
-				super.paint(g);
-
-				for (Rectangle r : regions) {
-					g.setColor(Color.white);
-					g.drawRect(r.x, r.y, r.width, r.height);
-					g.drawRect(r.x + 1, r.y + 1, r.width, r.height);
-				}
-				if (currentRect != null) {
-					Rectangle newRect = translateRect(currentRect);
-					if (newRect != null) {
-						if (doesIntersect(newRect)) {
-							g.setColor(Color.red);
-							g.drawRect(newRect.x, newRect.y, newRect.width,
-									newRect.height);
-							g.drawRect(newRect.x + 1, newRect.y + 1,
-									newRect.width, newRect.height);
-						} else {
-							g.setColor(Color.orange);
-							g.drawRect(newRect.x, newRect.y, newRect.width,
-									newRect.height);
-							g.drawRect(newRect.x + 1, newRect.y + 1,
-									newRect.width, newRect.height);
-						}
-					}
-				}
-			}
-		};
-
-		setTransferHandler(new FileTransferHandler());
-		img.setTransferHandler(new AnnotationTransferHandler());
-
-		img.addMouseListener(new MouseListener() {
-
-			public void mouseClicked(MouseEvent e) {
-
-			}
-
-			public void mouseEntered(MouseEvent e) {
-				currentRect = null;
-				SacePanelImage.this.repaint();
-			}
-
-			public void mouseExited(MouseEvent e) {
-				currentRect = null;
-				SacePanelImage.this.repaint();
-			}
-
-			public void mousePressed(MouseEvent e) {
-				currentRect = new Rectangle(e.getX(), e.getY(), 0, 0);
-				SacePanelImage.this.repaint();
-			}
-
-			public void mouseReleased(MouseEvent e) {
-				Rectangle newRect = translateRect(currentRect);
-				if (newRect != null) {
-					if (!doesIntersect(newRect))
-						regions.add(newRect);
-					currentRect = null;
-					SacePanelImage.this.repaint();
-				}
-			}
-
-		});
-
-		img.addMouseMotionListener(new MouseMotionListener() {
-
-			public void mouseDragged(MouseEvent e) {
-				if (currentRect != null) {
-					currentRect.height = e.getY() - currentRect.y;
-					currentRect.width = e.getX() - currentRect.x;
-
-					SacePanelImage.this.repaint();
-				}
-			}
-
-			public void mouseMoved(MouseEvent e) {
-			}
-
-		});
-
-		setLayout(new GridBagLayout());
-
-		add(img);
-
-		// DEBUG//
-		setImage("./src/main/resources/germany.jpg");
-	}
-
-	private boolean doesIntersect(Rectangle rect) {
-		if (rect != null) {
-			for (Rectangle r : regions) {
-				if (r.intersects(rect)) {
-					return true;
-				}
-			}
-		}
-		return false;
-	}
-
-	private Rectangle getRectangleToPoint(Point p) {
-		if (p != null)
-			for (Rectangle r : regions) {
-				if (r.contains(p))
-					return r;
-			}
-		return null;
-	}
-
-	public void setImage(String filename) {
-		image = Toolkit.getDefaultToolkit().getImage(filename);
-		ImageIcon ii = new ImageIcon(image);
-		if (ii.getImageLoadStatus() == MediaTracker.COMPLETE
-				|| ii.getImageLoadStatus() == MediaTracker.LOADING) {
-			imageFilename = filename;
-			img.setText("");
-			img.setIcon(ii);
-		} else {
-			img.setText("<drop image here>");
-		}
-	}
-
-	class AnnotationTransferHandler extends TransferHandler {
-
-		/**
-		 * 
-		 */
-		private static final long serialVersionUID = -4564763585453555835L;
-
-		@Override
-		public boolean importData(JComponent comp, Transferable t) {
-
-			try {
-				if (t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
-					Object o = t.getTransferData(DataFlavor.stringFlavor);
-
-					if (o instanceof TextAnnotation) {
-						Rectangle r = getRectangleToPoint(comp
-								.getMousePosition());
-
-						if (r != null) {
-							ImageAnnotation ia = new ImageAnnotation();
-							ia.setAnnotation(((TextAnnotation) o));
-							ia.setRegion(r);
-							ia.setFilename(imageFilename);
-							saceGUI.submitImageAnnotationToFISE(ia);
-						}
-					}
-					return true;
-				}
-			} catch (UnsupportedFlavorException e) {
-				e.printStackTrace();
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-			return false;
-		}
-
-		@Override
-		public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) {
-			return true;
-		}
-
-	}
-
-	class FileTransferHandler extends TransferHandler {
-
-		/**
-		 * 
-		 */
-		private static final long serialVersionUID = -4564763585453555835L;
-
-		@Override
-		public boolean importData(JComponent comp, Transferable t) {
-
-			try {
-				if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
-					List fileList = (java.util.List) t
-							.getTransferData(DataFlavor.javaFileListFlavor);
-
-					Object o = fileList.get(0);
-					if (o instanceof File) {
-						File f = (File) o;
-
-						if (f.exists() && f.isFile()) {
-							String mimeType = getMimeType(f);
-
-							if (mimeType.contains("image")) {
-								setImage(f.getAbsolutePath());
-								return true;
-							}
-						}
-					}
-				}
-			} catch (UnsupportedFlavorException e) {
-				e.printStackTrace();
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-			return false;
-		}
-
-		private String getMimeType(File f) throws java.io.IOException,
-				MalformedURLException {
-			String type = null;
-			URL u = f.toURI().toURL();
-			URLConnection uc = null;
-			uc = u.openConnection();
-			type = uc.getContentType();
-			return type;
-		}
-
-		@Override
-		public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) {
-			return true;
-		}
+    /**
+     *
+     */
+    private static final long serialVersionUID = -7607274145586243340L;
+
+    private SaceGUI saceGUI;
+
+    private Image image;
+    private String imageFilename;
+    private JLabel img;
+
+    private Rectangle currentRect = null;
+    private List<Rectangle> regions;
+
+    public SacePanelImage(SaceGUI gui) {
+        super();
+        saceGUI = gui;
+
+        init();
+
+    }
+
+    public void clear() {
+        imageFilename = "";
+        img.setText("<drop image here>");
+        img.setIcon(null);
+    }
+
+    private Rectangle translateRect(Rectangle r) {
+        Rectangle newRect = new Rectangle();
+        if (r != null) {
+            if (r.width < 0) {
+                newRect.x = r.x + r.width;
+                newRect.width = -r.width;
+            } else {
+                newRect.x = r.x;
+                newRect.width = r.width;
+            }
+            if (r.height < 0) {
+                newRect.y = r.y + r.height;
+                newRect.height = -r.height;
+            } else {
+                newRect.y = r.y;
+                newRect.height = r.height;
+            }
+            return newRect;
+        }
+        return r;
+    }
+
+    private void init() {
+        currentRect = null;
+        this.regions = new LinkedList<Rectangle>();
+        img = new JLabel("<drop image here>") {
+            /**
+             *
+             */
+            private static final long serialVersionUID = 9085980562151354916L;
+
+            @Override
+            public void paint(Graphics g) {
+                super.paint(g);
+
+                for (Rectangle r : regions) {
+                    g.setColor(Color.white);
+                    g.drawRect(r.x, r.y, r.width, r.height);
+                    g.drawRect(r.x + 1, r.y + 1, r.width, r.height);
+                }
+                if (currentRect != null) {
+                    Rectangle newRect = translateRect(currentRect);
+                    if (newRect != null) {
+                        if (doesIntersect(newRect)) {
+                            g.setColor(Color.red);
+                            g.drawRect(newRect.x, newRect.y, newRect.width,
+                                    newRect.height);
+                            g.drawRect(newRect.x + 1, newRect.y + 1,
+                                    newRect.width, newRect.height);
+                        } else {
+                            g.setColor(Color.orange);
+                            g.drawRect(newRect.x, newRect.y, newRect.width,
+                                    newRect.height);
+                            g.drawRect(newRect.x + 1, newRect.y + 1,
+                                    newRect.width, newRect.height);
+                        }
+                    }
+                }
+            }
+        };
+
+        setTransferHandler(new FileTransferHandler());
+        img.setTransferHandler(new AnnotationTransferHandler());
+
+        img.addMouseListener(new MouseListener() {
+
+            public void mouseClicked(MouseEvent e) {
+
+            }
+
+            public void mouseEntered(MouseEvent e) {
+                currentRect = null;
+                SacePanelImage.this.repaint();
+            }
+
+            public void mouseExited(MouseEvent e) {
+                currentRect = null;
+                SacePanelImage.this.repaint();
+            }
+
+            public void mousePressed(MouseEvent e) {
+                currentRect = new Rectangle(e.getX(), e.getY(), 0, 0);
+                SacePanelImage.this.repaint();
+            }
+
+            public void mouseReleased(MouseEvent e) {
+                Rectangle newRect = translateRect(currentRect);
+                if (newRect != null) {
+                    if (!doesIntersect(newRect))
+                        regions.add(newRect);
+                    currentRect = null;
+                    SacePanelImage.this.repaint();
+                }
+            }
+
+        });
+
+        img.addMouseMotionListener(new MouseMotionListener() {
+
+            public void mouseDragged(MouseEvent e) {
+                if (currentRect != null) {
+                    currentRect.height = e.getY() - currentRect.y;
+                    currentRect.width = e.getX() - currentRect.x;
+
+                    SacePanelImage.this.repaint();
+                }
+            }
+
+            public void mouseMoved(MouseEvent e) {
+            }
+
+        });
+
+        setLayout(new GridBagLayout());
+
+        add(img);
+
+        // DEBUG//
+        setImage("./src/main/resources/germany.jpg");
+    }
+
+    private boolean doesIntersect(Rectangle rect) {
+        if (rect != null) {
+            for (Rectangle r : regions) {
+                if (r.intersects(rect)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    private Rectangle getRectangleToPoint(Point p) {
+        if (p != null)
+            for (Rectangle r : regions) {
+                if (r.contains(p))
+                    return r;
+            }
+        return null;
+    }
+
+    public void setImage(String filename) {
+        image = Toolkit.getDefaultToolkit().getImage(filename);
+        ImageIcon ii = new ImageIcon(image);
+        if (ii.getImageLoadStatus() == MediaTracker.COMPLETE
+                || ii.getImageLoadStatus() == MediaTracker.LOADING) {
+            imageFilename = filename;
+            img.setText("");
+            img.setIcon(ii);
+        } else {
+            img.setText("<drop image here>");
+        }
+    }
+
+    class AnnotationTransferHandler extends TransferHandler {
+
+        /**
+         *
+         */
+        private static final long serialVersionUID = -4564763585453555835L;
+
+        @Override
+        public boolean importData(JComponent comp, Transferable t) {
+
+            try {
+                if (t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
+                    Object o = t.getTransferData(DataFlavor.stringFlavor);
+
+                    if (o instanceof TextAnnotation) {
+                        Rectangle r = getRectangleToPoint(comp
+                                .getMousePosition());
+
+                        if (r != null) {
+                            ImageAnnotation ia = new ImageAnnotation();
+                            ia.setAnnotation(((TextAnnotation) o));
+                            ia.setRegion(r);
+                            ia.setFilename(imageFilename);
+                            saceGUI.submitImageAnnotationToFISE(ia);
+                        }
+                    }
+                    return true;
+                }
+            } catch (UnsupportedFlavorException e) {
+                e.printStackTrace();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+            return false;
+        }
+
+        @Override
+        public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) {
+            return true;
+        }
+
+    }
+
+    class FileTransferHandler extends TransferHandler {
+
+        /**
+         *
+         */
+        private static final long serialVersionUID = -4564763585453555835L;
+
+        @Override
+        public boolean importData(JComponent comp, Transferable t) {
+
+            try {
+                if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
+                    List fileList = (java.util.List) t
+                            .getTransferData(DataFlavor.javaFileListFlavor);
+
+                    Object o = fileList.get(0);
+                    if (o instanceof File) {
+                        File f = (File) o;
+
+                        if (f.exists() && f.isFile()) {
+                            String mimeType = getMimeType(f);
+
+                            if (mimeType.contains("image")) {
+                                setImage(f.getAbsolutePath());
+                                return true;
+                            }
+                        }
+                    }
+                }
+            } catch (UnsupportedFlavorException e) {
+                e.printStackTrace();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+            return false;
+        }
+
+        private String getMimeType(File f) throws java.io.IOException,
+                MalformedURLException {
+            String type = null;
+            URL u = f.toURI().toURL();
+            URLConnection uc = null;
+            uc = u.openConnection();
+            type = uc.getContentType();
+            return type;
+        }
+
+        @Override
+        public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) {
+            return true;
+        }
 
-	}
+    }
 
 }

Modified: incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/ui/SacePanelText.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/ui/SacePanelText.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/ui/SacePanelText.java (original)
+++ incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/ui/SacePanelText.java Sun Dec 12 16:10:48 2010
@@ -26,283 +26,283 @@ import eu.iksproject.fise.sace.util.Text
 
 public class SacePanelText extends JPanel {
 
-	private static final long serialVersionUID = 3407471836299691149L;
+    private static final long serialVersionUID = 3407471836299691149L;
 
-	private SaceGUI saceGUI;
+    private SaceGUI saceGUI;
 
-	private List<TextAnnotation> textAnnotations;
-	private List<DocumentAnnotation> docAnnotations;
+    private List<TextAnnotation> textAnnotations;
+    private List<DocumentAnnotation> docAnnotations;
 
-	private JTextArea editor;
-	private Highlighter highlighter;
-	private Highlighter.HighlightPainter myHighlightPainter = new MyHighlightPainter();
-
-	public SacePanelText(SaceGUI gui) {
-		super();
-		saceGUI = gui;
-
-		init();
-	}
-
-	public void clear() {
-		editor.getHighlighter().removeAllHighlights();
-		editor.setText("");
-		textAnnotations.clear();
-		docAnnotations.clear();
-	}
-
-	private void init() {
-		setLayout(new BorderLayout());
-		textAnnotations = new LinkedList<TextAnnotation>();
-		docAnnotations = new LinkedList<DocumentAnnotation>();
-
-		editor = new JTextArea();
-		editor.setDisabledTextColor(editor.getForeground());
-		editor.setLineWrap(true);
-		editor.setSelectionColor(editor.getBackground());
-		editor.setWrapStyleWord(true);
-		highlighter = editor.getHighlighter();
-
-		editor.addMouseListener(new MouseListener() {
-
-			public void mouseClicked(MouseEvent e) {
-				if (e.isPopupTrigger() || e.isMetaDown()) {
-					int index = editor.viewToModel(e.getPoint());
-					if (index >= 0 && index < editor.getText().length()) {
-						// check if there are text-annotations!
-						TextAnnotation annot = findAnnotationForIndex(index);
-
-						if (annot != null) {
-							// open the popup menu
-							PopupMenu pm = getPopupMenuForTextAnnotation(annot);
-							pm.show(editor, e.getX(), e.getY());
-						}
-					} else {
-						// present document annotations if available!
-						if (!docAnnotations.isEmpty()) {
-							// open the popup menu
-							PopupMenu pm = getPopupMenuForDocumentAnnotations(docAnnotations);
-							pm.show(editor, e.getX(), e.getY());
-						}
-					}
-				}
-			}
-
-			public void mouseEntered(MouseEvent e) {
-			}
-
-			public void mouseExited(MouseEvent e) {
-			}
-
-			public void mousePressed(MouseEvent e) {
-				if (!e.isPopupTrigger() && !e.isMetaDown()) {
-					int index = editor.viewToModel(e.getPoint());
-					if (index >= 0 && index < editor.getText().length()) {
-						// check if there are text-annotations!
-						TextAnnotation annot = findAnnotationForIndex(index);
-
-						if (annot != null) {
-							((MyTransferHandler) editor.getTransferHandler())
-									.exportAsDrag(editor, e,
-											TransferHandler.COPY);
-						}
-					}
-				}
-			}
-
-			public void mouseReleased(MouseEvent e) {
-			}
-		});
-
-		editor.setDragEnabled(true);
-		editor.setTransferHandler(new MyTransferHandler());
-
-		// DEBUG //
-		editor
-				.setText("In the picture on the right, you can see the line-up of the German football team. This picture seems to be an older version as Michael Ballack is not able to participate this year's World Cup championship, due to an injury.");
-
-		add(BorderLayout.CENTER, new JScrollPane(editor,
-				JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
-				JScrollPane.HORIZONTAL_SCROLLBAR_NEVER));
-	}
-
-	private TextAnnotation findAnnotationForIndex(int index) {
-		for (TextAnnotation ta : textAnnotations) {
-			if (ta.getStartIndex() <= index && index <= ta.getEndIndex())
-				return ta;
-		}
-		return null;
-	}
-
-	private PopupMenu getPopupMenuForTextAnnotation(
-			final TextAnnotation annotation) {
-
-		final PopupMenu pm = new PopupMenu();
-		MenuItem mi = new MenuItem("Please choose one annotation for '"
-				+ annotation.getSelectedText() + "'!");
-		mi.setEnabled(false);
-		pm.add(mi);
-		pm.addSeparator();
-
-		String creatorTA = annotation.getCreator().replaceFirst(".*\\.(.*)$",
-				"$1");
-		if (annotation.getAttribute("type") != null) {
-			for (String type : annotation.getAttribute("type")) {
-				final String typeTmp = type;
-				if (!type.endsWith("Thing")) {
-					String label = type.replaceFirst(".*\\/(.*)$", "$1")
-							+ " <-- " + creatorTA;
-					boolean alreadyThere = false;
-					for (int i = 0; i < pm.getItemCount(); i++)
-						alreadyThere |= (pm.getItem(i).getLabel().equals(label));
-
-					if (!alreadyThere) {
-						mi = new MenuItem(label);
-						mi.addActionListener(new ActionListener() {
-							public void actionPerformed(ActionEvent e) {
-								SacePanelText.this.remove(pm);
-								retainTextTypeAnnotation(annotation, typeTmp);
-								submitAnnotationToFISE(annotation);
-							}
-						});
-						pm.add(mi);
-					}
-				}
-			}
-		}
-
-		for (int j = 0; j < annotation.getEntityAnnotations().size(); j++) {
-			final EntityAnnotation ea = annotation.getEntityAnnotations()
-					.get(j);
-			String creatorEA = ea.getCreator().replaceFirst(".*\\.(.*)$", "$1");
-			for (String type : ea.getAttribute("entity-type")) {
-				final String typeTmp = type;
-				if (!type.endsWith("Thing")) {
-					String label = type.replaceFirst(".*\\/(.*)$", "$1")
-							+ " <-- " + creatorEA;
-					boolean alreadyThere = false;
-					for (int i = 0; i < pm.getItemCount(); i++)
-						alreadyThere |= (pm.getItem(i).getLabel().equals(label));
-
-					if (!alreadyThere) {
-						mi = new MenuItem(label);
-						mi.addActionListener(new ActionListener() {
-							public void actionPerformed(ActionEvent e) {
-								SacePanelText.this.remove(pm);
-								retainTextEntityTypeAnnotation(annotation, ea,
-										typeTmp);
-								submitAnnotationToFISE(annotation);
-							}
-						});
-						pm.add(mi);
-					}
-				}
-			}
-		}
-		this.add(pm);
-		return pm;
-	}
-
-	private void retainTextTypeAnnotation(TextAnnotation textAnnot, String type) {
-		textAnnot.clearEntityAnnotation();
-		textAnnot.retainTypeAnnotation(type);
-	}
-
-	private void retainTextEntityTypeAnnotation(TextAnnotation textAnnot,
-			EntityAnnotation ea, String entityType) {
-		textAnnot.clearTypeAnnotation();
-		ea.retainTypeAnnotation(entityType);
-	}
-
-	private PopupMenu getPopupMenuForDocumentAnnotations(
-			List<DocumentAnnotation> docAnnotations) {
-		final PopupMenu pm = new PopupMenu();
-		MenuItem mi = new MenuItem(
-				"Please choose one annotation for the document!");
-		mi.setEnabled(false);
-		pm.add(mi);
-		pm.addSeparator();
-
-		for (DocumentAnnotation da : docAnnotations) {
-
-			mi = new MenuItem(da.getAttribute("lang")
-					+ " <-- LanguageIdentifier");
-			mi.addActionListener(new ActionListener() {
-				public void actionPerformed(ActionEvent e) {
-					SacePanelText.this.remove(pm);
-					submitAnnotationToFISE(null);
-				}
-			});
-			pm.add(mi);
-		}
-		this.add(pm);
-		return pm;
-	}
-
-	private void submitAnnotationToFISE(TextAnnotation ta) {
-		saceGUI.submitTextAnnotationToFISE(ta);
-	}
-
-	class MyHighlightPainter extends DefaultHighlighter.DefaultHighlightPainter {
-		public MyHighlightPainter() {
-			super(new Color(65, 137, 77));
-			// super(Color.red);
-		}
-	}
-
-	public void addDocumentAnnotation(DocumentAnnotation annot) {
-		docAnnotations.add(annot);
-	}
-
-	public void addTextAnnotation(TextAnnotation ta) {
-		textAnnotations.add(ta);
-
-		try {
-			highlighter.addHighlight(ta.getStartIndex(), ta.getEndIndex(),
-					this.myHighlightPainter);
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-	}
-
-	public String getText() {
-		return editor.getText();
-	}
-
-	class MyTransferHandler extends TransferHandler {
-
-		/**
-		 * 
-		 */
-		private static final long serialVersionUID = -7247031090902543381L;
-
-		@Override
-		public Transferable createTransferable(JComponent c) {
-
-			if (c instanceof JTextArea) {
-				JTextArea jta = (JTextArea) c;
-
-				int index = editor.viewToModel(jta.getMousePosition());
-				if (index >= 0 && index < editor.getText().length()) {
-					// check if there are text-annotations!
-					TextAnnotation annot = findAnnotationForIndex(index);
-
-					if (annot != null) {
-						return annot;
-					}
-				}
-			}
-			return null;
-		}
-
-		@Override
-		public int getSourceActions(JComponent c) {
-			return COPY;
-		}
+    private JTextArea editor;
+    private Highlighter highlighter;
+    private Highlighter.HighlightPainter myHighlightPainter = new MyHighlightPainter();
+
+    public SacePanelText(SaceGUI gui) {
+        super();
+        saceGUI = gui;
+
+        init();
+    }
+
+    public void clear() {
+        editor.getHighlighter().removeAllHighlights();
+        editor.setText("");
+        textAnnotations.clear();
+        docAnnotations.clear();
+    }
+
+    private void init() {
+        setLayout(new BorderLayout());
+        textAnnotations = new LinkedList<TextAnnotation>();
+        docAnnotations = new LinkedList<DocumentAnnotation>();
+
+        editor = new JTextArea();
+        editor.setDisabledTextColor(editor.getForeground());
+        editor.setLineWrap(true);
+        editor.setSelectionColor(editor.getBackground());
+        editor.setWrapStyleWord(true);
+        highlighter = editor.getHighlighter();
+
+        editor.addMouseListener(new MouseListener() {
+
+            public void mouseClicked(MouseEvent e) {
+                if (e.isPopupTrigger() || e.isMetaDown()) {
+                    int index = editor.viewToModel(e.getPoint());
+                    if (index >= 0 && index < editor.getText().length()) {
+                        // check if there are text-annotations!
+                        TextAnnotation annot = findAnnotationForIndex(index);
+
+                        if (annot != null) {
+                            // open the popup menu
+                            PopupMenu pm = getPopupMenuForTextAnnotation(annot);
+                            pm.show(editor, e.getX(), e.getY());
+                        }
+                    } else {
+                        // present document annotations if available!
+                        if (!docAnnotations.isEmpty()) {
+                            // open the popup menu
+                            PopupMenu pm = getPopupMenuForDocumentAnnotations(docAnnotations);
+                            pm.show(editor, e.getX(), e.getY());
+                        }
+                    }
+                }
+            }
+
+            public void mouseEntered(MouseEvent e) {
+            }
+
+            public void mouseExited(MouseEvent e) {
+            }
+
+            public void mousePressed(MouseEvent e) {
+                if (!e.isPopupTrigger() && !e.isMetaDown()) {
+                    int index = editor.viewToModel(e.getPoint());
+                    if (index >= 0 && index < editor.getText().length()) {
+                        // check if there are text-annotations!
+                        TextAnnotation annot = findAnnotationForIndex(index);
+
+                        if (annot != null) {
+                            ((MyTransferHandler) editor.getTransferHandler())
+                                    .exportAsDrag(editor, e,
+                                            TransferHandler.COPY);
+                        }
+                    }
+                }
+            }
+
+            public void mouseReleased(MouseEvent e) {
+            }
+        });
+
+        editor.setDragEnabled(true);
+        editor.setTransferHandler(new MyTransferHandler());
+
+        // DEBUG //
+        editor
+                .setText("In the picture on the right, you can see the line-up of the German football team. This picture seems to be an older version as Michael Ballack is not able to participate this year's World Cup championship, due to an injury.");
+
+        add(BorderLayout.CENTER, new JScrollPane(editor,
+                JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+                JScrollPane.HORIZONTAL_SCROLLBAR_NEVER));
+    }
+
+    private TextAnnotation findAnnotationForIndex(int index) {
+        for (TextAnnotation ta : textAnnotations) {
+            if (ta.getStartIndex() <= index && index <= ta.getEndIndex())
+                return ta;
+        }
+        return null;
+    }
+
+    private PopupMenu getPopupMenuForTextAnnotation(
+            final TextAnnotation annotation) {
+
+        final PopupMenu pm = new PopupMenu();
+        MenuItem mi = new MenuItem("Please choose one annotation for '"
+                + annotation.getSelectedText() + "'!");
+        mi.setEnabled(false);
+        pm.add(mi);
+        pm.addSeparator();
+
+        String creatorTA = annotation.getCreator().replaceFirst(".*\\.(.*)$",
+                "$1");
+        if (annotation.getAttribute("type") != null) {
+            for (String type : annotation.getAttribute("type")) {
+                final String typeTmp = type;
+                if (!type.endsWith("Thing")) {
+                    String label = type.replaceFirst(".*\\/(.*)$", "$1")
+                            + " <-- " + creatorTA;
+                    boolean alreadyThere = false;
+                    for (int i = 0; i < pm.getItemCount(); i++)
+                        alreadyThere |= (pm.getItem(i).getLabel().equals(label));
+
+                    if (!alreadyThere) {
+                        mi = new MenuItem(label);
+                        mi.addActionListener(new ActionListener() {
+                            public void actionPerformed(ActionEvent e) {
+                                SacePanelText.this.remove(pm);
+                                retainTextTypeAnnotation(annotation, typeTmp);
+                                submitAnnotationToFISE(annotation);
+                            }
+                        });
+                        pm.add(mi);
+                    }
+                }
+            }
+        }
+
+        for (int j = 0; j < annotation.getEntityAnnotations().size(); j++) {
+            final EntityAnnotation ea = annotation.getEntityAnnotations()
+                    .get(j);
+            String creatorEA = ea.getCreator().replaceFirst(".*\\.(.*)$", "$1");
+            for (String type : ea.getAttribute("entity-type")) {
+                final String typeTmp = type;
+                if (!type.endsWith("Thing")) {
+                    String label = type.replaceFirst(".*\\/(.*)$", "$1")
+                            + " <-- " + creatorEA;
+                    boolean alreadyThere = false;
+                    for (int i = 0; i < pm.getItemCount(); i++)
+                        alreadyThere |= (pm.getItem(i).getLabel().equals(label));
+
+                    if (!alreadyThere) {
+                        mi = new MenuItem(label);
+                        mi.addActionListener(new ActionListener() {
+                            public void actionPerformed(ActionEvent e) {
+                                SacePanelText.this.remove(pm);
+                                retainTextEntityTypeAnnotation(annotation, ea,
+                                        typeTmp);
+                                submitAnnotationToFISE(annotation);
+                            }
+                        });
+                        pm.add(mi);
+                    }
+                }
+            }
+        }
+        this.add(pm);
+        return pm;
+    }
+
+    private void retainTextTypeAnnotation(TextAnnotation textAnnot, String type) {
+        textAnnot.clearEntityAnnotation();
+        textAnnot.retainTypeAnnotation(type);
+    }
+
+    private void retainTextEntityTypeAnnotation(TextAnnotation textAnnot,
+            EntityAnnotation ea, String entityType) {
+        textAnnot.clearTypeAnnotation();
+        ea.retainTypeAnnotation(entityType);
+    }
+
+    private PopupMenu getPopupMenuForDocumentAnnotations(
+            List<DocumentAnnotation> docAnnotations) {
+        final PopupMenu pm = new PopupMenu();
+        MenuItem mi = new MenuItem(
+                "Please choose one annotation for the document!");
+        mi.setEnabled(false);
+        pm.add(mi);
+        pm.addSeparator();
+
+        for (DocumentAnnotation da : docAnnotations) {
+
+            mi = new MenuItem(da.getAttribute("lang")
+                    + " <-- LanguageIdentifier");
+            mi.addActionListener(new ActionListener() {
+                public void actionPerformed(ActionEvent e) {
+                    SacePanelText.this.remove(pm);
+                    submitAnnotationToFISE(null);
+                }
+            });
+            pm.add(mi);
+        }
+        this.add(pm);
+        return pm;
+    }
+
+    private void submitAnnotationToFISE(TextAnnotation ta) {
+        saceGUI.submitTextAnnotationToFISE(ta);
+    }
+
+    class MyHighlightPainter extends DefaultHighlighter.DefaultHighlightPainter {
+        public MyHighlightPainter() {
+            super(new Color(65, 137, 77));
+            // super(Color.red);
+        }
+    }
+
+    public void addDocumentAnnotation(DocumentAnnotation annot) {
+        docAnnotations.add(annot);
+    }
+
+    public void addTextAnnotation(TextAnnotation ta) {
+        textAnnotations.add(ta);
+
+        try {
+            highlighter.addHighlight(ta.getStartIndex(), ta.getEndIndex(),
+                    this.myHighlightPainter);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public String getText() {
+        return editor.getText();
+    }
+
+    class MyTransferHandler extends TransferHandler {
+
+        /**
+         *
+         */
+        private static final long serialVersionUID = -7247031090902543381L;
+
+        @Override
+        public Transferable createTransferable(JComponent c) {
+
+            if (c instanceof JTextArea) {
+                JTextArea jta = (JTextArea) c;
+
+                int index = editor.viewToModel(jta.getMousePosition());
+                if (index >= 0 && index < editor.getText().length()) {
+                    // check if there are text-annotations!
+                    TextAnnotation annot = findAnnotationForIndex(index);
+
+                    if (annot != null) {
+                        return annot;
+                    }
+                }
+            }
+            return null;
+        }
+
+        @Override
+        public int getSourceActions(JComponent c) {
+            return COPY;
+        }
 
-	}
+    }
 
-	public void finalizeText() {
-	}
+    public void finalizeText() {
+    }
 
 }

Modified: incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/util/DocumentAnnotation.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/util/DocumentAnnotation.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/util/DocumentAnnotation.java (original)
+++ incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/util/DocumentAnnotation.java Sun Dec 12 16:10:48 2010
@@ -7,54 +7,54 @@ import java.util.Hashtable;
 import java.util.Set;
 
 public class DocumentAnnotation implements IAnnotation {
-	
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = 1461648698204231096L;
-
-	private String name;
-	
-	private Hashtable<String, String> attributes;
-	
-	public DocumentAnnotation () {
-		attributes = new Hashtable<String, String>();
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-	
-	public String getName() {
-		return name;
-	}
-	
-	public void addAttribute(String key, String value) {
-		attributes.put(key, value);
-	}
-	
-	public String getAttribute(String key) {
-		return attributes.get(key);
-	}
-	
-	public Set<String> listAttributeKeys () {
-		return attributes.keySet();
-	}
-
-	public Object getTransferData(DataFlavor flavor)
-			throws UnsupportedFlavorException, IOException {
-		return this;
-	}
-
-	public DataFlavor[] getTransferDataFlavors() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	public boolean isDataFlavorSupported(DataFlavor flavor) {
-		// TODO Auto-generated method stub
-		return false;
-	}
+
+    /**
+     *
+     */
+    private static final long serialVersionUID = 1461648698204231096L;
+
+    private String name;
+
+    private Hashtable<String, String> attributes;
+
+    public DocumentAnnotation () {
+        attributes = new Hashtable<String, String>();
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void addAttribute(String key, String value) {
+        attributes.put(key, value);
+    }
+
+    public String getAttribute(String key) {
+        return attributes.get(key);
+    }
+
+    public Set<String> listAttributeKeys () {
+        return attributes.keySet();
+    }
+
+    public Object getTransferData(DataFlavor flavor)
+            throws UnsupportedFlavorException, IOException {
+        return this;
+    }
+
+    public DataFlavor[] getTransferDataFlavors() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public boolean isDataFlavorSupported(DataFlavor flavor) {
+        // TODO Auto-generated method stub
+        return false;
+    }
 
 
 }

Modified: incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/util/EntityAnnotation.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/util/EntityAnnotation.java?rev=1044841&r1=1044840&r2=1044841&view=diff
==============================================================================
--- incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/util/EntityAnnotation.java (original)
+++ incubator/stanbol/trunk/fise/SemiAutomaticContentEnhancer/src/main/java/eu/iksproject/fise/sace/util/EntityAnnotation.java Sun Dec 12 16:10:48 2010
@@ -9,84 +9,84 @@ import java.util.List;
 
 public class EntityAnnotation implements IAnnotation {
 
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = -4729630243302760317L;
-	private String name;
-	private String creator;
-	private String created;
-	private String relation;
-
-	private Hashtable<String, List<String>> attributes;
-
-	public EntityAnnotation() {
-		attributes = new Hashtable<String, List<String>>();
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setCreator(String creator) {
-		this.creator = creator;
-	}
-
-	public String getCreator() {
-		return creator;
-	}
-
-	public void setCreated(String created) {
-		this.created = created;
-	}
-
-	public void setRelation(String relation) {
-		this.relation = relation;
-	}
-
-	public String getRelation() {
-		return relation;
-	}
-
-	public void addAttribute(String key, String value) {
-		if (attributes.containsKey(key)) {
-			List<String> val = attributes.remove(key);
-			val.add(value);
-			attributes.put(key, val);
-		} else {
-			List<String> val = new LinkedList<String>();
-			val.add(value);
-			attributes.put(key, val);
-		}
-	}
-
-	public List<String> getAttribute(String key) {
-		return attributes.get(key);
-	}
-
-	public Object getTransferData(DataFlavor flavor)
-			throws UnsupportedFlavorException, IOException {
-		return this;
-	}
-
-	public DataFlavor[] getTransferDataFlavors() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	public boolean isDataFlavorSupported(DataFlavor flavor) {
-		// TODO Auto-generated method stub
-		return false;
-	}
-
-	public void retainTypeAnnotation(String typeTmp) {
-		List<String> newList = new LinkedList<String>();
-		newList.add(typeTmp);
-		attributes.put("entity-type", newList);
-	}
+    /**
+     *
+     */
+    private static final long serialVersionUID = -4729630243302760317L;
+    private String name;
+    private String creator;
+    private String created;
+    private String relation;
+
+    private Hashtable<String, List<String>> attributes;
+
+    public EntityAnnotation() {
+        attributes = new Hashtable<String, List<String>>();
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setCreator(String creator) {
+        this.creator = creator;
+    }
+
+    public String getCreator() {
+        return creator;
+    }
+
+    public void setCreated(String created) {
+        this.created = created;
+    }
+
+    public void setRelation(String relation) {
+        this.relation = relation;
+    }
+
+    public String getRelation() {
+        return relation;
+    }
+
+    public void addAttribute(String key, String value) {
+        if (attributes.containsKey(key)) {
+            List<String> val = attributes.remove(key);
+            val.add(value);
+            attributes.put(key, val);
+        } else {
+            List<String> val = new LinkedList<String>();
+            val.add(value);
+            attributes.put(key, val);
+        }
+    }
+
+    public List<String> getAttribute(String key) {
+        return attributes.get(key);
+    }
+
+    public Object getTransferData(DataFlavor flavor)
+            throws UnsupportedFlavorException, IOException {
+        return this;
+    }
+
+    public DataFlavor[] getTransferDataFlavors() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public boolean isDataFlavorSupported(DataFlavor flavor) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public void retainTypeAnnotation(String typeTmp) {
+        List<String> newList = new LinkedList<String>();
+        newList.add(typeTmp);
+        attributes.put("entity-type", newList);
+    }
 
 }