You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ctakes.apache.org by se...@apache.org on 2017/03/27 14:37:46 UTC
svn commit: r1788936 [3/7] - in /ctakes/trunk: ctakes-gui-res/
ctakes-gui-res/src/ ctakes-gui-res/src/main/
ctakes-gui-res/src/main/resources/ ctakes-gui-res/src/main/resources/org/
ctakes-gui-res/src/main/resources/org/apache/ ctakes-gui-res/src/main/...
Added: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/dictionary/data/tiny/UnwantedPrefixes.txt
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/dictionary/data/tiny/UnwantedPrefixes.txt?rev=1788936&view=auto
==============================================================================
--- ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/dictionary/data/tiny/UnwantedPrefixes.txt (added)
+++ ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/dictionary/data/tiny/UnwantedPrefixes.txt Mon Mar 27 14:37:44 2017
@@ -0,0 +1 @@
+// No unwanted prefixes for tiny, only removal
\ No newline at end of file
Added: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/dictionary/data/tiny/UnwantedSuffixes.txt
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/dictionary/data/tiny/UnwantedSuffixes.txt?rev=1788936&view=auto
==============================================================================
--- ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/dictionary/data/tiny/UnwantedSuffixes.txt (added)
+++ ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/dictionary/data/tiny/UnwantedSuffixes.txt Mon Mar 27 14:37:44 2017
@@ -0,0 +1,4 @@
+/
+'
+-
+,
Added: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/dictionary/data/tiny/UnwantedTexts.txt
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/dictionary/data/tiny/UnwantedTexts.txt?rev=1788936&view=auto
==============================================================================
--- ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/dictionary/data/tiny/UnwantedTexts.txt (added)
+++ ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/dictionary/data/tiny/UnwantedTexts.txt Mon Mar 27 14:37:44 2017
@@ -0,0 +1,61 @@
+// today brand veterinary product. 310367
+today
+// tomorrow brand. 310370
+tomorrow
+// active brand of pseudoephedrine. 718247
+active
+// rid pediculicide product. 73361
+rid
+// tandem medication. 75804
+tandem
+// amen medication. 305236
+amen
+// revive brand of caffeiene. 310031
+revive
+// at 10 medication. 591126
+at 10
+// perform medication. 2947996
+perform
+// level medication. 2946261
+level
+// hypermethioninemia. 268621
+met
+// multiple endocrine neoplasia. 27662
+men
+// attention deficit disorder. 4269
+add
+// glutemate oxaloacetate. 4002
+got
+// nitrous oxide. 132555
+nos
+// fish eye disease. 342895
+fed
+// epidermodysplasia verruciformis. 14522
+ever
+// ethacrynic acid. 14963
+ea
+// s - adenosylmethionine. 36002
+same
+// glanzmann 's thrombasthenia. 40015
+gt
+// left thigh. 230426
+lt
+// right thigh. 230425. radiologic therapy. 1522449. refractory thrombocytopaenia. 2826321
+rt
+// dry skin. 151908
+dry
+// LSD. 202406
+acid
+// termination of pregnancy. 392535. topical. 1710439
+top
+// lupus erythematosus tumidus. 406636
+let
+// histamine dihydrochloride. 543456
+hist
+// date allergenic extract. 2740799
+date
+// aim toothpaste. 2948600
+aim
+// primary acquired melanosis. 3263719
+pam
+
Added: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/BlueArrowOut.png
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/BlueArrowOut.png?rev=1788936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/BlueArrowOut.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/BlueGear.png
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/BlueGear.png?rev=1788936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/BlueGear.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/BlueGearYellowGear.png
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/BlueGearYellowGear.png?rev=1788936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/BlueGearYellowGear.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/BlueRightArrow.png
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/BlueRightArrow.png?rev=1788936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/BlueRightArrow.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/FindOnPc_48.png
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/FindOnPc_48.png?rev=1788936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/FindOnPc_48.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/GreenArrowIn.png
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/GreenArrowIn.png?rev=1788936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/GreenArrowIn.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/Help_32.png
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/Help_32.png?rev=1788936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/Help_32.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/Help_48.png
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/Help_48.png?rev=1788936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/Help_48.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/NewPiper.png
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/NewPiper.png?rev=1788936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/NewPiper.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/OpenPiper.png
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/OpenPiper.png?rev=1788936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/OpenPiper.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/PiperFile.png
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/PiperFile.png?rev=1788936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/PiperFile.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/RunPiper.png
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/RunPiper.png?rev=1788936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/RunPiper.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/SavePiper.png
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/SavePiper.png?rev=1788936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/SavePiper.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/Utilities.png
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/Utilities.png?rev=1788936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/Utilities.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/Write.png
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/Write.png?rev=1788936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/Write.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/bluedown.png
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/bluedown.png?rev=1788936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/bluedown.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/blueup.png
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/blueup.png?rev=1788936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/blueup.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/redcircleno.png
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/redcircleno.png?rev=1788936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ctakes/trunk/ctakes-gui-res/src/main/resources/org/apache/ctakes/gui/pipeline/icon/redcircleno.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ctakes/trunk/ctakes-gui/ctakes-gui.iml
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui/ctakes-gui.iml?rev=1788936&view=auto
==============================================================================
--- ctakes/trunk/ctakes-gui/ctakes-gui.iml (added)
+++ ctakes/trunk/ctakes-gui/ctakes-gui.iml Mon Mar 27 14:37:44 2017
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/target/classes" />
+ <output-test url="file://$MODULE_DIR$/target/test-classes" />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
+ <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
+ <excludeFolder url="file://$MODULE_DIR$/target" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module" module-name="ctakes-gui-res" />
+ <orderEntry type="module" module-name="ctakes-core" />
+ <orderEntry type="module" module-name="ctakes-core-res" />
+ <orderEntry type="module" module-name="ctakes-type-system" />
+ <orderEntry type="library" name="Maven: org.apache.uima:uimaj-core:2.9.0" level="project" />
+ <orderEntry type="library" name="Maven: tw.edu.ntu.csie:libsvm:3.1" level="project" />
+ <orderEntry type="module" module-name="ctakes-utils" />
+ <orderEntry type="library" name="Maven: org.apache.lucene:lucene-queries:4.0.0" level="project" />
+ <orderEntry type="library" name="Maven: org.apache.lucene:lucene-queryparser:4.0.0" level="project" />
+ <orderEntry type="library" name="Maven: org.apache.lucene:lucene-sandbox:4.0.0" level="project" />
+ <orderEntry type="library" name="Maven: jakarta-regexp:jakarta-regexp:1.4" level="project" />
+ <orderEntry type="library" name="Maven: org.apache.lucene:lucene-analyzers-common:4.0.0" level="project" />
+ <orderEntry type="library" name="Maven: org.springframework:spring-context:3.1.2.RELEASE" level="project" />
+ <orderEntry type="library" name="Maven: org.springframework:spring-aop:3.1.2.RELEASE" level="project" />
+ <orderEntry type="library" name="Maven: aopalliance:aopalliance:1.0" level="project" />
+ <orderEntry type="library" name="Maven: org.springframework:spring-beans:3.1.2.RELEASE" level="project" />
+ <orderEntry type="library" name="Maven: org.springframework:spring-core:3.1.2.RELEASE" level="project" />
+ <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.1" level="project" />
+ <orderEntry type="library" name="Maven: org.springframework:spring-expression:3.1.2.RELEASE" level="project" />
+ <orderEntry type="library" name="Maven: org.springframework:spring-asm:3.1.2.RELEASE" level="project" />
+ <orderEntry type="library" name="Maven: commons-io:commons-io:2.0.1" level="project" />
+ <orderEntry type="library" name="Maven: jdom:jdom:1.0" level="project" />
+ <orderEntry type="library" name="Maven: org.jdom:jdom2:2.0.3" level="project" />
+ <orderEntry type="library" name="Maven: org.cleartk:cleartk-util:2.0.0" level="project" />
+ <orderEntry type="library" name="Maven: com.google.guava:guava:10.0" level="project" />
+ <orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" />
+ <orderEntry type="library" name="Maven: org.apache.opennlp:opennlp-tools:1.7.2" level="project" />
+ <orderEntry type="library" name="Maven: org.apache.opennlp:opennlp-maxent:3.0.3" level="project" />
+ <orderEntry type="library" name="Maven: org.apache.lucene:lucene-core:4.0.0" level="project" />
+ <orderEntry type="library" name="Maven: edu.mit.findstruct:findstructapi:0.0.1" level="project" />
+ <orderEntry type="library" name="Maven: com.googlecode.armbrust-file-utils:sqlwrapper:0.0.1" level="project" />
+ <orderEntry type="library" name="Maven: net.sourceforge.openai:openaifsm:0.0.1" level="project" />
+ <orderEntry type="library" name="Maven: org.apache.uima:uimaj-examples:2.9.0" level="project" />
+ <orderEntry type="library" name="Maven: org.apache.uima:uimaj-cpe:2.9.0" level="project" />
+ <orderEntry type="library" name="Maven: org.apache.uima:uimaj-adapter-vinci:2.9.0" level="project" />
+ <orderEntry type="library" name="Maven: org.apache.uima:jVinci:2.9.0" level="project" />
+ <orderEntry type="library" name="Maven: org.apache.uima:uimaj-document-annotation:2.5.0" level="project" />
+ <orderEntry type="library" name="Maven: org.apache.uima:uimaj-tools:2.9.0" level="project" />
+ <orderEntry type="library" name="Maven: com.lexicalscope.jewelcli:jewelcli:0.8.3" level="project" />
+ <orderEntry type="library" name="Maven: org.apache.uima:uimafit-core:2.2.0" level="project" />
+ <orderEntry type="library" name="Maven: commons-lang:commons-lang:2.4" level="project" />
+ <orderEntry type="library" name="Maven: commons-logging:commons-logging-api:1.1" level="project" />
+ <orderEntry type="library" name="Maven: org.cleartk:cleartk-ml:2.0.0" level="project" />
+ <orderEntry type="library" name="Maven: hsqldb:hsqldb:1.8.0.10" level="project" />
+ <orderEntry type="library" name="Maven: log4j:log4j:1.2.16" level="project" />
+ <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.10" level="project" />
+ <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
+ <orderEntry type="library" name="Maven: io.github.lukehutch:fast-classpath-scanner:2.0.18" level="project" />
+ </component>
+</module>
\ No newline at end of file
Added: ctakes/trunk/ctakes-gui/pom.xml
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui/pom.xml?rev=1788936&view=auto
==============================================================================
--- ctakes/trunk/ctakes-gui/pom.xml (added)
+++ ctakes/trunk/ctakes-gui/pom.xml Mon Mar 27 14:37:44 2017
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.ctakes</groupId>
+ <artifactId>ctakes</artifactId>
+ <version>3.2.3-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>ctakes-gui</artifactId>
+ <name>ctakes-gui</name>
+ <description>module with gui components and simple run tools</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ctakes</groupId>
+ <artifactId>ctakes-gui-res</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ctakes</groupId>
+ <artifactId>ctakes-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.10</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.github.lukehutch</groupId>
+ <artifactId>fast-classpath-scanner</artifactId>
+ <version>LATEST</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
Added: ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/action/GlobalHotKeyManager.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/action/GlobalHotKeyManager.java?rev=1788936&view=auto
==============================================================================
--- ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/action/GlobalHotKeyManager.java (added)
+++ ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/action/GlobalHotKeyManager.java Mon Mar 27 14:37:44 2017
@@ -0,0 +1,75 @@
+package org.apache.ctakes.gui.action;
+
+
+import org.apache.log4j.Logger;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 11/29/2016
+ */
+final public class GlobalHotKeyManager extends EventQueue implements HotKeyManager {
+ static private final HotKeyManager INSTANCE = new GlobalHotKeyManager();
+
+ static public HotKeyManager getInstance() {
+ return INSTANCE;
+ }
+
+ static {
+ // here we register ourselves as a new link in the chain of
+ // responsibility
+ Toolkit.getDefaultToolkit().getSystemEventQueue().push( (EventQueue)INSTANCE );
+ }
+
+ private GlobalHotKeyManager() {
+ }
+
+ static private final Logger LOGGER = Logger.getLogger( "HotKeyManager" );
+
+ private final InputMap _keyStrokes = new InputMap();
+ private final ActionMap _actions = new ActionMap();
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addHotKey( final String name, final KeyStroke keyStroke, final Action action ) {
+ _keyStrokes.put( keyStroke, name );
+ _actions.put( name, action );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void dispatchEvent( final AWTEvent event ) {
+ if ( event instanceof KeyEvent ) {
+ // KeyStroke.getKeyStrokeForEvent converts an ordinary KeyEvent
+ // to a keystroke, as stored in the InputMap. Keep in mind that
+ // Numpad keystrokes are different to ordinary keys, i.e. if you
+ // are listening to
+ final KeyStroke ks = KeyStroke.getKeyStrokeForEvent( (KeyEvent)event );
+ String actionKey = (String)_keyStrokes.get( ks );
+ if ( actionKey != null ) {
+ final Action action = _actions.get( actionKey );
+ if ( action != null && action.isEnabled() ) {
+ // I'm not sure about the parameters
+ action.actionPerformed(
+ new ActionEvent( event.getSource(), event.getID(),
+ actionKey, ((InputEvent)event).getModifiers() ) );
+ return; // consume event
+ }
+ }
+ }
+ super.dispatchEvent( event ); // let the next in chain handle event
+ }
+
+
+}
Added: ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/action/HotKeyManager.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/action/HotKeyManager.java?rev=1788936&view=auto
==============================================================================
--- ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/action/HotKeyManager.java (added)
+++ ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/action/HotKeyManager.java Mon Mar 27 14:37:44 2017
@@ -0,0 +1,14 @@
+package org.apache.ctakes.gui.action;
+
+import javax.swing.*;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 11/29/2016
+ */
+public interface HotKeyManager {
+
+ void addHotKey( final String name, final KeyStroke keyStroke, final Action action );
+
+}
Added: ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/CellRendererLabel.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/CellRendererLabel.java?rev=1788936&view=auto
==============================================================================
--- ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/CellRendererLabel.java (added)
+++ ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/CellRendererLabel.java Mon Mar 27 14:37:44 2017
@@ -0,0 +1,99 @@
+package org.apache.ctakes.gui.component;
+
+
+import org.apache.log4j.Logger;
+
+import javax.swing.*;
+import java.awt.*;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 3/24/2017
+ */
+public class CellRendererLabel extends JLabel {
+
+ static private final Logger LOGGER = Logger.getLogger( "CellRendererLabel" );
+
+ public CellRendererLabel() {
+ super();
+ }
+
+ public CellRendererLabel( final Icon icon ) {
+ super( icon );
+ }
+
+ public CellRendererLabel( final String text ) {
+ super( text );
+ }
+
+ @Override
+ public void validate() {
+ }
+
+ @Override
+ public void invalidate() {
+ }
+
+ @Override
+ public void repaint() {
+ }
+
+ @Override
+ public void revalidate() {
+ }
+
+ @Override
+ public void repaint( long tm, int x, int y, int width, int height ) {
+ }
+
+ @Override
+ public void repaint( Rectangle r ) {
+ }
+
+ @Override
+ protected void firePropertyChange( String propertyName, Object oldValue, Object newValue ) {
+ // Strings get interned...
+ if ( propertyName == "text"
+ || ((propertyName == "font" || propertyName == "foreground")
+ && oldValue != newValue
+ && getClientProperty( javax.swing.plaf.basic.BasicHTML.propertyKey ) != null) ) {
+
+ super.firePropertyChange( propertyName, oldValue, newValue );
+ }
+ }
+
+ @Override
+ public void firePropertyChange( String propertyName, byte oldValue, byte newValue ) {
+ }
+
+ @Override
+ public void firePropertyChange( String propertyName, char oldValue, char newValue ) {
+ }
+
+ @Override
+ public void firePropertyChange( String propertyName, short oldValue, short newValue ) {
+ }
+
+ @Override
+ public void firePropertyChange( String propertyName, int oldValue, int newValue ) {
+ }
+
+ @Override
+ public void firePropertyChange( String propertyName, long oldValue, long newValue ) {
+ }
+
+ @Override
+ public void firePropertyChange( String propertyName, float oldValue, float newValue ) {
+ }
+
+ @Override
+ public void firePropertyChange( String propertyName, double oldValue, double newValue ) {
+ }
+
+ @Override
+ public void firePropertyChange( String propertyName, boolean oldValue, boolean newValue ) {
+ }
+
+
+}
Added: ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/CellRendererPanel.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/CellRendererPanel.java?rev=1788936&view=auto
==============================================================================
--- ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/CellRendererPanel.java (added)
+++ ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/CellRendererPanel.java Mon Mar 27 14:37:44 2017
@@ -0,0 +1,177 @@
+package org.apache.ctakes.gui.component;
+
+
+import org.apache.log4j.Logger;
+
+import javax.swing.*;
+import java.awt.*;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 1/31/2017
+ */
+final public class CellRendererPanel extends JPanel {
+
+ static private final Logger LOGGER = Logger.getLogger( "CellRendererPanel" );
+
+
+ public CellRendererPanel( final LayoutManager layoutManager ) {
+ super( layoutManager );
+ setBackground( null );
+ }
+
+ /**
+ * Overridden for performance reasons.
+ * See the <a href="#override">Implementation Note</a>
+ * for more information.
+ *
+ * @return <code>true</code> if the background is completely opaque
+ * and differs from the JList's background;
+ * <code>false</code> otherwise
+ * @since 1.5
+ */
+ @Override
+ public boolean isOpaque() {
+ Color back = getBackground();
+ Component p = getParent();
+ if ( p != null ) {
+ p = p.getParent();
+ }
+ // p should now be the JList.
+ boolean colorMatch = (back != null) && (p != null) &&
+ back.equals( p.getBackground() ) &&
+ p.isOpaque();
+ return !colorMatch && super.isOpaque();
+ }
+
+
+ /**
+ * Overridden for performance reasons.
+ * See the <a href="#override">Implementation Note</a>
+ * for more information.
+ *
+ * @since 1.5
+ */
+ @Override
+ public void repaint() {
+ }
+
+ /**
+ * Overridden for performance reasons.
+ * See the <a href="#override">Implementation Note</a>
+ * for more information.
+ */
+ @Override
+ public void revalidate() {
+ }
+
+ /**
+ * Overridden for performance reasons.
+ * See the <a href="#override">Implementation Note</a>
+ * for more information.
+ */
+ @Override
+ public void repaint( long tm, int x, int y, int width, int height ) {
+ }
+
+ /**
+ * Overridden for performance reasons.
+ * See the <a href="#override">Implementation Note</a>
+ * for more information.
+ */
+ @Override
+ public void repaint( Rectangle r ) {
+ }
+
+ /**
+ * Overridden for performance reasons.
+ * See the <a href="#override">Implementation Note</a>
+ * for more information.
+ */
+ @Override
+ protected void firePropertyChange( String propertyName, Object oldValue, Object newValue ) {
+ // Strings get interned...
+ if ( propertyName == "text"
+ || ((propertyName == "font" || propertyName == "foreground")
+ && oldValue != newValue
+ && getClientProperty( javax.swing.plaf.basic.BasicHTML.propertyKey ) != null) ) {
+
+ super.firePropertyChange( propertyName, oldValue, newValue );
+ }
+ }
+
+ /**
+ * Overridden for performance reasons.
+ * See the <a href="#override">Implementation Note</a>
+ * for more information.
+ */
+ @Override
+ public void firePropertyChange( String propertyName, byte oldValue, byte newValue ) {
+ }
+
+ /**
+ * Overridden for performance reasons.
+ * See the <a href="#override">Implementation Note</a>
+ * for more information.
+ */
+ @Override
+ public void firePropertyChange( String propertyName, char oldValue, char newValue ) {
+ }
+
+ /**
+ * Overridden for performance reasons.
+ * See the <a href="#override">Implementation Note</a>
+ * for more information.
+ */
+ @Override
+ public void firePropertyChange( String propertyName, short oldValue, short newValue ) {
+ }
+
+ /**
+ * Overridden for performance reasons.
+ * See the <a href="#override">Implementation Note</a>
+ * for more information.
+ */
+ @Override
+ public void firePropertyChange( String propertyName, int oldValue, int newValue ) {
+ }
+
+ /**
+ * Overridden for performance reasons.
+ * See the <a href="#override">Implementation Note</a>
+ * for more information.
+ */
+ @Override
+ public void firePropertyChange( String propertyName, long oldValue, long newValue ) {
+ }
+
+ /**
+ * Overridden for performance reasons.
+ * See the <a href="#override">Implementation Note</a>
+ * for more information.
+ */
+ @Override
+ public void firePropertyChange( String propertyName, float oldValue, float newValue ) {
+ }
+
+ /**
+ * Overridden for performance reasons.
+ * See the <a href="#override">Implementation Note</a>
+ * for more information.
+ */
+ @Override
+ public void firePropertyChange( String propertyName, double oldValue, double newValue ) {
+ }
+
+ /**
+ * Overridden for performance reasons.
+ * See the <a href="#override">Implementation Note</a>
+ * for more information.
+ */
+ @Override
+ public void firePropertyChange( String propertyName, boolean oldValue, boolean newValue ) {
+ }
+
+
+}
Added: ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/DisablerPane.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/DisablerPane.java?rev=1788936&view=auto
==============================================================================
--- ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/DisablerPane.java (added)
+++ ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/DisablerPane.java Mon Mar 27 14:37:44 2017
@@ -0,0 +1,226 @@
+package org.apache.ctakes.gui.component;
+
+import org.apache.log4j.Logger;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+
+/**
+ * A Panel that makes everything on the GUI "disabled".
+ * Useful when there is a resource-heavy thread running and GUI interaction is undesirable.
+ *
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 11/29/2016
+ */
+public final class DisablerPane extends JPanel implements MouseListener,
+ MouseMotionListener,
+ FocusListener {
+
+ static public DisablerPane getInstance() {
+ return InstanceHolder.INSTANCE;
+ }
+
+ static private final class InstanceHolder {
+ static private final DisablerPane INSTANCE = new DisablerPane();
+ }
+
+ static private final Logger LOGGER = Logger.getLogger( "DisablerPane" );
+
+ private JMenuBar _menuBar;
+ private Container _contentPane;
+
+ private boolean _dragging = false;
+ private boolean _needToRedispatch = false;
+
+ private DisablerPane() {
+ addMouseListener( this );
+ addMouseMotionListener( this );
+ addFocusListener( this );
+ setOpaque( false );
+ setVisible( false );
+ }
+
+ /**
+ * The DisablerPane must be initialized before it can be used
+ *
+ * @param frame -
+ */
+ public void initialize( final JFrame frame ) {
+ _menuBar = frame.getJMenuBar();
+ _contentPane = frame.getContentPane();
+ frame.setGlassPane( this );
+ }
+
+ /**
+ * We only need to redispatch if we're not visible, but having full control
+ * over this might prove handy.
+ */
+ public void setNeedToRedispatch( final boolean need ) {
+ _needToRedispatch = need;
+ }
+
+ /**
+ * Paint partially transparent grey over the frame
+ * {@inheritDoc}
+ */
+ @Override
+ protected void paintComponent( final Graphics g ) {
+ if ( !isVisible() ) {
+ return;
+ }
+ g.setColor( new Color( 127, 127, 127, 83 ) );
+ g.fillRect( 0, 0, getWidth(), getHeight() );
+ }
+
+ /**
+ * Blocks input if visible
+ * {@inheritDoc}
+ */
+ @Override
+ public void setVisible( final boolean visible ) {
+ // Make sure we grab the focus so that key events don't go astray.
+ if ( visible ) {
+ requestFocus();
+ }
+ super.setVisible( visible );
+ }
+
+ /**
+ * Once we have focus, keep it if we're visible
+ * {@inheritDoc}
+ */
+ @Override
+ public void focusLost( final FocusEvent event ) {
+ if ( isVisible() ) {
+ requestFocus();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void focusGained( final FocusEvent event ) {
+ }
+
+ /*
+ * (Based on code from the Java Tutorial) We must forward at least the mouse
+ * drags that started with mouse presses over the check box. Otherwise, when
+ * the user presses the check box then drags off, the check box isn't
+ * disarmed -- it keeps its dark gray background or whatever its L&F uses to
+ * indicate that the button is currently being pressed.
+ */
+ @Override
+ public void mouseDragged( final MouseEvent event ) {
+ if ( _needToRedispatch ) {
+ forwardMouseEvent( event );
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void mouseMoved( final MouseEvent event ) {
+ if ( _needToRedispatch ) {
+ forwardMouseEvent( event );
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void mouseClicked( final MouseEvent event ) {
+ if ( _needToRedispatch ) {
+ forwardMouseEvent( event );
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void mouseEntered( final MouseEvent event ) {
+ if ( _needToRedispatch ) {
+ forwardMouseEvent( event );
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void mouseExited( final MouseEvent event ) {
+ if ( _needToRedispatch ) {
+ forwardMouseEvent( event );
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void mousePressed( final MouseEvent event ) {
+ if ( _needToRedispatch ) {
+ forwardMouseEvent( event );
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void mouseReleased( final MouseEvent event ) {
+ if ( _needToRedispatch ) {
+ forwardMouseEvent( event );
+ _dragging = false;
+ }
+ }
+
+ /**
+ * If there is a mouse event, forward to an underlying component
+ *
+ * @param event -
+ */
+ private void forwardMouseEvent( final MouseEvent event ) {
+ if ( _contentPane == null || _menuBar == null ) {
+ LOGGER.error( "DisablerPane has not been initialized with a Frame" );
+ return;
+ }
+ boolean inMenuBar = false;
+ final Point point = event.getPoint();
+ Component component;
+ Container container = _contentPane;
+ Point containerPoint = SwingUtilities.convertPoint( this, point, _contentPane );
+ final int eventID = event.getID();
+
+ if ( containerPoint.y < 0 ) {
+ inMenuBar = true;
+ container = _menuBar;
+ containerPoint = SwingUtilities.convertPoint( this, point, _menuBar );
+ isDragging( eventID );
+ }
+ component = SwingUtilities.getDeepestComponentAt( container, containerPoint.x, containerPoint.y );
+ if ( component == null ) {
+ return;
+ } else {
+ isDragging( eventID );
+ }
+ if ( inMenuBar || _dragging ) {
+ final Point componentPoint = SwingUtilities.convertPoint( this, point, component );
+ component.dispatchEvent( new MouseEvent( component, eventID, event.getWhen(), event.getModifiers(),
+ componentPoint.x, componentPoint.y, event.getClickCount(), event.isPopupTrigger() ) );
+ }
+ }
+
+ private void isDragging( final int eventID ) {
+ if ( eventID == MouseEvent.MOUSE_PRESSED ) {
+ _dragging = true;
+ }
+ }
+
+
+}
Added: ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/FileChooserPanel.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/FileChooserPanel.java?rev=1788936&view=auto
==============================================================================
--- ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/FileChooserPanel.java (added)
+++ ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/FileChooserPanel.java Mon Mar 27 14:37:44 2017
@@ -0,0 +1,132 @@
+package org.apache.ctakes.gui.component;
+
+import org.apache.log4j.Logger;
+
+import javax.swing.*;
+import javax.swing.border.EmptyBorder;
+import javax.swing.text.JTextComponent;
+import java.awt.*;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.DropTargetDropEvent;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 12/10/2015
+ */
+final public class FileChooserPanel extends JPanel {
+
+ static private final Logger LOGGER = Logger.getLogger( "FileChooserPanel" );
+
+ public FileChooserPanel( final String name, final String defaultDirectory,
+ final ActionListener fileChangeListener ) {
+ this( name, defaultDirectory, false, fileChangeListener );
+ }
+
+
+ public FileChooserPanel( final String name, final String defaultDirectory, final boolean selectDir,
+ final ActionListener fileChangeListener ) {
+ super( new BorderLayout( 10, 10 ) );
+ setBorder( new EmptyBorder( 2, 10, 2, 10 ) );
+ final JLabel label = new JLabel( name );
+ label.setPreferredSize( new Dimension( 100, 0 ) );
+ label.setHorizontalAlignment( SwingConstants.TRAILING );
+ final JTextField textField = new JTextField( defaultDirectory );
+ textField.setEditable( false );
+ final JButton openChooserButton
+ = new JButton( new OpenFileChooserAction( textField, selectDir, fileChangeListener ) );
+ add( label, BorderLayout.WEST );
+ add( textField, BorderLayout.CENTER );
+ add( openChooserButton, BorderLayout.EAST );
+
+ textField.setDropTarget( new FileDropTarget( textField, selectDir, fileChangeListener ) );
+ textField.addActionListener( fileChangeListener );
+ }
+
+ /**
+ * Opens the JFileChooser
+ */
+ static private class OpenFileChooserAction extends AbstractAction {
+ private final JFileChooser __chooser;
+ private final JTextComponent __textComponent;
+ private final ActionListener __fileChangeListener;
+
+ private OpenFileChooserAction( final JTextComponent textComponent, final boolean selectDir,
+ final ActionListener dirChangeListener ) {
+ super( "Select " + (selectDir ? "Directory" : "File") );
+ __textComponent = textComponent;
+ __chooser = new JFileChooser();
+ __chooser.setFileSelectionMode( (selectDir ? JFileChooser.DIRECTORIES_ONLY : JFileChooser.FILES_ONLY) );
+ __fileChangeListener = dirChangeListener;
+ }
+
+ @Override
+ public void actionPerformed( final ActionEvent event ) {
+ final String startDirPath = __textComponent.getText();
+ if ( startDirPath != null && !startDirPath.isEmpty() ) {
+ final File startingDir = new File( startDirPath );
+ if ( startingDir.exists() ) {
+ __chooser.setCurrentDirectory( startingDir );
+ }
+ }
+ final int option = __chooser.showOpenDialog( null );
+ if ( option != JFileChooser.APPROVE_OPTION ) {
+ return;
+ }
+ final File file = __chooser.getSelectedFile();
+ __textComponent.setText( file.getAbsolutePath() );
+ final ActionEvent fileEvent = new ActionEvent( this, ActionEvent.ACTION_FIRST, file.getAbsolutePath() );
+ __fileChangeListener.actionPerformed( fileEvent );
+ }
+ }
+
+
+ static private class FileDropTarget extends DropTarget {
+ private final JTextComponent __textComponent;
+ private final ActionListener __fileChangeListener;
+ private final boolean __selectDir;
+
+ private FileDropTarget( final JTextComponent textComponent, final boolean selectDir,
+ final ActionListener dirChangeListener ) {
+ __textComponent = textComponent;
+ __selectDir = selectDir;
+ __fileChangeListener = dirChangeListener;
+ }
+
+ @Override
+ public synchronized void drop( final DropTargetDropEvent event ) {
+ event.acceptDrop( DnDConstants.ACTION_COPY );
+ try {
+ final Object values = event.getTransferable().getTransferData( DataFlavor.javaFileListFlavor );
+ if ( !(values instanceof Iterable) ) {
+ return;
+ }
+ for ( Object value : (Iterable)values ) {
+ if ( !(value instanceof File) ) {
+ continue;
+ }
+ final File file = (File)value;
+ if ( file.isDirectory() != __selectDir ) {
+ continue;
+ }
+ __textComponent.setText( file.getAbsolutePath() );
+ final ActionEvent fileEvent
+ = new ActionEvent( this, ActionEvent.ACTION_FIRST, file.getAbsolutePath() );
+ __fileChangeListener.actionPerformed( fileEvent );
+ return;
+ }
+ } catch ( UnsupportedFlavorException | IOException multE ) {
+ LOGGER.warn( multE.getMessage() );
+ }
+ }
+ }
+
+
+}
Added: ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/LoggerPanel.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/LoggerPanel.java?rev=1788936&view=auto
==============================================================================
--- ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/LoggerPanel.java (added)
+++ ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/LoggerPanel.java Mon Mar 27 14:37:44 2017
@@ -0,0 +1,132 @@
+package org.apache.ctakes.gui.component;
+
+import org.apache.log4j.Appender;
+import org.apache.log4j.AppenderSkeleton;
+import org.apache.log4j.Level;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.spi.LoggingEvent;
+
+import javax.swing.*;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Document;
+import javax.swing.text.PlainDocument;
+import java.util.Arrays;
+import java.util.Collection;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 11/29/2016
+ */
+final public class LoggerPanel extends JScrollPane {
+
+
+ static public LoggerPanel createLoggerPanel( final Level... levels ) {
+ final LoggerPanel panel = new LoggerPanel( levels );
+ LogManager.getRootLogger().addAppender( panel.getLogHandler() );
+ return panel;
+ }
+
+ static private final Level[] ALL_LEVELS = { Level.FATAL, Level.ERROR, Level.WARN, Level.INFO, Level.DEBUG,
+ Level.TRACE };
+
+
+ private final Appender _appender;
+ private final Document _textAreaDoc = new PlainDocument();
+
+ /**
+ * text gui that will display log4j messages
+ */
+ private LoggerPanel( final Level... levels ) {
+ final JTextArea textArea = new JTextArea( _textAreaDoc );
+ textArea.setEditable( false );
+ textArea.setEnabled( false );
+ super.setViewportView( textArea );
+ _appender = new LogHandler( levels );
+ }
+
+ /**
+ * @return all the text in this gui
+ */
+ public String getText() {
+ try {
+ return _textAreaDoc.getText( 0, _textAreaDoc.getLength() );
+ } catch ( BadLocationException blE ) {
+ return "";
+ }
+ }
+
+ /**
+ * clear the text in this gui
+ */
+ public void clearText() {
+ SwingUtilities.invokeLater( () -> {
+ try {
+ _textAreaDoc.remove( 0, _textAreaDoc.getLength() );
+ } catch ( BadLocationException blE ) {
+ //
+ }
+ } );
+ }
+
+ /**
+ * @param text to append to the text displayed in this gui
+ */
+ public void appendText( final String text ) {
+ SwingUtilities.invokeLater( () -> {
+ try {
+ _textAreaDoc.insertString( _textAreaDoc.getLength(), text, null );
+ } catch ( BadLocationException blE ) {
+ //
+ }
+ } );
+ }
+
+
+ /**
+ * @return the log4j appender that handles logging
+ */
+ private Appender getLogHandler() {
+ return _appender;
+ }
+
+ /**
+ * Handles reception of logging messages
+ */
+ private class LogHandler extends AppenderSkeleton {
+ private final Collection<Level> _levels;
+
+ private LogHandler( final Level... levels ) {
+ _levels = Arrays.asList( (levels.length == 0 ? ALL_LEVELS : levels) );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void append( final LoggingEvent event ) {
+ if ( _levels.contains( event.getLevel() ) ) {
+ appendText( event.getMessage().toString() + "\n" );
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @return false
+ */
+ @Override
+ public boolean requiresLayout() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void close() {
+ }
+ }
+
+
+}
Added: ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/PositionedSplitPane.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/PositionedSplitPane.java?rev=1788936&view=auto
==============================================================================
--- ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/PositionedSplitPane.java (added)
+++ ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/PositionedSplitPane.java Mon Mar 27 14:37:44 2017
@@ -0,0 +1,96 @@
+package org.apache.ctakes.gui.component;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.logging.Logger;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 11/29/2016
+ */
+final public class PositionedSplitPane extends JSplitPane {
+
+ static private final Logger LOGGER = Logger.getLogger( "PositionedSplitPane" );
+
+ private boolean _isLocationSet;
+ private int _pixelLocation = -1;
+ private double _proportionalLocation = -1d;
+
+ /**
+ * {@inheritDoc}
+ */
+ public PositionedSplitPane() {
+ super();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public PositionedSplitPane( final int orientation ) {
+ super( orientation );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public PositionedSplitPane( final int orientation, final boolean isContinuousLayout ) {
+ super( orientation, isContinuousLayout );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public PositionedSplitPane( final int orientation,
+ final Component leftComponent,
+ final Component rightComponent ) {
+ super( orientation, leftComponent, rightComponent );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public PositionedSplitPane( final int orientation,
+ final boolean isContinuousLayout,
+ final Component leftComponent,
+ final Component rightComponent ) {
+ super( orientation, isContinuousLayout, leftComponent, rightComponent );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setDividerLocation( final double proportionalLocation ) {
+ super.setDividerLocation( proportionalLocation );
+ _proportionalLocation = proportionalLocation;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setDividerLocation( final int pixelLocation ) {
+ super.setDividerLocation( pixelLocation );
+ _pixelLocation = pixelLocation;
+ }
+
+ /**
+ * If this is the first paint, set the divider location first. Fixes a bug (imo) in Java.
+ * {@inheritDoc}
+ */
+ @Override
+ public void paint( final Graphics g ) {
+ if ( !_isLocationSet || getDividerLocation() < 0 ) {
+ if ( _pixelLocation > 0 ) {
+ super.setDividerLocation( _pixelLocation );
+ } else if ( _proportionalLocation > 0 ) {
+ super.setDividerLocation( _proportionalLocation );
+ }
+ _isLocationSet = true;
+ }
+ super.paint( g );
+ }
+
+}
Added: ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/SmoothTipList.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/SmoothTipList.java?rev=1788936&view=auto
==============================================================================
--- ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/SmoothTipList.java (added)
+++ ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/SmoothTipList.java Mon Mar 27 14:37:44 2017
@@ -0,0 +1,24 @@
+package org.apache.ctakes.gui.component;
+
+import javax.swing.*;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 1/13/2017
+ */
+public class SmoothTipList<T> extends JList<T> {
+
+ public SmoothTipList( final ListModel<T> model ) {
+ super( model );
+ }
+
+ @Override
+ public JToolTip createToolTip() {
+ final SmoothToolTip tip = new SmoothToolTip();
+ tip.setComponent( this );
+ return tip;
+ }
+
+
+}
Added: ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/SmoothTipTable.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/SmoothTipTable.java?rev=1788936&view=auto
==============================================================================
--- ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/SmoothTipTable.java (added)
+++ ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/SmoothTipTable.java Mon Mar 27 14:37:44 2017
@@ -0,0 +1,24 @@
+package org.apache.ctakes.gui.component;
+
+import javax.swing.*;
+import javax.swing.table.TableModel;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 12/23/2016
+ */
+public class SmoothTipTable extends JTable {
+
+ public SmoothTipTable( final TableModel model ) {
+ super( model );
+ }
+
+ @Override
+ public JToolTip createToolTip() {
+ final SmoothToolTip tip = new SmoothToolTip();
+ tip.setComponent( this );
+ return tip;
+ }
+
+}
Added: ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/SmoothToolTip.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/SmoothToolTip.java?rev=1788936&view=auto
==============================================================================
--- ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/SmoothToolTip.java (added)
+++ ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/SmoothToolTip.java Mon Mar 27 14:37:44 2017
@@ -0,0 +1,128 @@
+package org.apache.ctakes.gui.component;
+
+
+import sun.swing.SwingUtilities2;
+
+import javax.swing.*;
+import javax.swing.plaf.ToolTipUI;
+import javax.swing.plaf.basic.BasicToolTipUI;
+import java.awt.*;
+import java.awt.geom.RoundRectangle2D;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 12/23/2016
+ */
+public class SmoothToolTip extends JToolTip {
+
+ private static final String UI_CLASS_ID = "SmoothToolTipUI";
+
+ /**
+ * This is set to true for the life of the <code>setUI</code> call.
+ */
+ private boolean _settingUI;
+
+ public SmoothToolTip() {
+ setBorder( null );
+ setOpaque( false );
+ }
+
+
+ /**
+ * @return the <code>TimelineUI</code> object that renders this component
+ */
+ @Override
+ final public ToolTipUI getUI() {
+ return (ToolTipUI)ui;
+ }
+
+ final public void setUI( final ToolTipUI ui ) {
+ if ( _settingUI ) {
+ return;
+ }
+ if ( this.ui != ui ) {
+ _settingUI = true;
+ try {
+ super.setUI( ui );
+ } finally {
+ _settingUI = false;
+ }
+ }
+ }
+
+ /**
+ * Notification from the <code>UIManager</code> that the L&F has changed.
+ * Replaces the current UI object with the latest version from the
+ * <code>UIManager</code>.
+ *
+ * @see JComponent#updateUI
+ */
+ @Override
+ final public void updateUI() {
+ setUI( new SmoothToolTipUI() );
+ }
+
+
+ /**
+ * Returns the name of the L&F class that renders this component.
+ *
+ * @return the string "TimelineUI"
+ * @see JComponent#getUIClassID
+ * @see UIDefaults#getUI
+ */
+ @Override
+ public String getUIClassID() {
+ return UI_CLASS_ID;
+ }
+
+ @Override
+ public void paintBorder( final Graphics g ) {
+ }
+
+
+ static private final class SmoothToolTipUI extends BasicToolTipUI {
+
+ @Override
+ public void update( Graphics g, JComponent c ) {
+ paint( g, c );
+ }
+
+ @Override
+ public void paint( final Graphics g, final JComponent comp ) {
+ final Font font = comp.getFont();
+ final FontMetrics metrics = SwingUtilities2.getFontMetrics( comp, g, font );
+ final Dimension size = comp.getSize();
+
+ final Color background = Color.YELLOW;//c.getBackground();
+// Color transground = new Color( background.getRed(), background.getGreen(), background.getBlue(), 127 );
+ Color transground = new Color( background.getRed(), background.getGreen(), background.getBlue(), 195 );
+ g.setColor( transground );
+ g.fillRoundRect( 0, 0, size.width, size.height, 6, 3 );
+
+ final Color foreground = comp.getForeground();
+ transground = new Color( foreground.getRed(), foreground.getGreen(), foreground.getBlue(), 195 );
+ g.setColor( transground );
+
+ // fix for bug 4153892
+ String tipText = ((JToolTip)comp).getTipText();
+ if ( tipText == null ) {
+ tipText = "";
+ }
+
+ final Insets insets = comp.getInsets();
+ final RoundRectangle2D.Float paintTextR = new RoundRectangle2D.Float(
+ insets.left + 3,
+ insets.top,
+ size.width - (insets.left + insets.right) - 6,
+ size.height - (insets.top + insets.bottom), 10, 10 );
+ g.setFont( font );
+ SwingUtilities2.drawString( comp, g, tipText, (int)paintTextR.getX(),
+ (int)paintTextR.getY() + metrics.getAscent() );
+ transground = new Color( foreground.getRed(), foreground.getGreen(), foreground.getBlue(), 63 );
+ g.setColor( transground );
+ g.drawRoundRect( 0, 0, size.width - 1, size.height - 1, 10, 10 );
+ }
+ }
+
+}
Added: ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/SystemOutPanel.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/SystemOutPanel.java?rev=1788936&view=auto
==============================================================================
--- ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/SystemOutPanel.java (added)
+++ ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/component/SystemOutPanel.java Mon Mar 27 14:37:44 2017
@@ -0,0 +1,139 @@
+package org.apache.ctakes.gui.component;
+
+import org.apache.log4j.Logger;
+
+import javax.annotation.concurrent.NotThreadSafe;
+import javax.swing.*;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Document;
+import javax.swing.text.PlainDocument;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+/**
+ * A Text Component that will output text that would normally go to the console for standard output or standard error
+ *
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 11/29/2016
+ */
+final public class SystemOutPanel extends JScrollPane {
+
+ static private final Logger LOGGER = Logger.getLogger( "SystemOutPanel" );
+
+
+ private final boolean _isStandardOutRedirect;
+ private final Document _textAreaDoc = new PlainDocument();
+ private PrintStream _oldStandardStream;
+
+ /**
+ * new text gui that will display standard output
+ */
+ public SystemOutPanel() {
+ this( true );
+ }
+
+ /**
+ * @param isStandardOutRedirect true if this gui is to display standard output, false for standard error
+ */
+ public SystemOutPanel( final boolean isStandardOutRedirect ) {
+ _isStandardOutRedirect = isStandardOutRedirect;
+ final JTextArea textArea = new JTextArea( _textAreaDoc );
+ textArea.setEditable( false );
+ super.setViewportView( textArea );
+ }
+
+ /**
+ * Starts redirecting standard output (or error) from the console (or other) to this gui
+ */
+ public void startRedirect() {
+ final PrintStream newStandardStream = new PrintStream( new UiOutputStream() );
+ clearText();
+ if ( _isStandardOutRedirect ) {
+ _oldStandardStream = System.out;
+ System.setOut( newStandardStream );
+ } else {
+ _oldStandardStream = System.err;
+ System.setErr( newStandardStream );
+ }
+ }
+
+ /**
+ * Stops redirecting the standard output (or error) and returns it to its former consumer
+ */
+ public void endRedirect() {
+ if ( _isStandardOutRedirect ) {
+ System.setOut( _oldStandardStream );
+ } else {
+ System.setErr( _oldStandardStream );
+ }
+ }
+
+ /**
+ * @return all the text in this gui
+ */
+ public String getText() {
+ try {
+ return _textAreaDoc.getText( 0, _textAreaDoc.getLength() );
+ } catch ( BadLocationException blE ) {
+ return "";
+ }
+ }
+
+ /**
+ * clear the text in this gui
+ */
+ public void clearText() {
+ SwingUtilities.invokeLater( () -> {
+ try {
+ _textAreaDoc.remove( 0, _textAreaDoc.getLength() );
+ } catch ( BadLocationException blE ) {
+ //
+ }
+ } );
+ }
+
+ /**
+ * @param text to append to the text displayed in this gui
+ */
+ public void appendText( final String text ) {
+ SwingUtilities.invokeLater( () -> {
+ try {
+ _textAreaDoc.insertString( _textAreaDoc.getLength(), text, null );
+ } catch ( BadLocationException blE ) {
+ //
+ }
+ } );
+ }
+
+ /**
+ * stream that will accept characters until a newline, then append the line to this gui
+ */
+ @NotThreadSafe
+ private class UiOutputStream extends OutputStream {
+ private final StringBuilder __sb = new StringBuilder();
+
+ public void write( final int b ) throws IOException {
+ __sb.append( (char)b );
+ if ( (char)b == '\n' ) {
+ appendText( __sb.toString() );
+ __sb.setLength( 0 );
+ }
+ }
+
+ public void flush() throws IOException {
+ appendText( __sb.toString() );
+ __sb.setLength( 0 );
+ super.flush();
+ }
+
+ public void close() throws IOException {
+ appendText( __sb.toString() );
+ __sb.setLength( 0 );
+ super.close();
+ }
+ }
+
+
+}
Added: ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/dictionary/DictionaryBuilder.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/dictionary/DictionaryBuilder.java?rev=1788936&view=auto
==============================================================================
--- ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/dictionary/DictionaryBuilder.java (added)
+++ ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/dictionary/DictionaryBuilder.java Mon Mar 27 14:37:44 2017
@@ -0,0 +1,215 @@
+package org.apache.ctakes.gui.dictionary;
+
+
+import org.apache.ctakes.core.util.collection.CollectionMap;
+import org.apache.ctakes.core.util.collection.HashSetMap;
+import org.apache.ctakes.gui.dictionary.umls.*;
+import org.apache.ctakes.gui.dictionary.util.HsqlUtil;
+import org.apache.ctakes.gui.dictionary.util.RareWordDbWriter;
+import org.apache.log4j.Logger;
+
+import java.io.File;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 12/11/2015
+ */
+final class DictionaryBuilder {
+
+ static private final Logger LOGGER = Logger.getLogger( "DictionaryBuilder" );
+
+ static private final String DEFAULT_DATA_DIR = "org/apache/ctakes/gui/dictionary/data/tiny";
+ static private final String CTAKES_APP_DB_PATH = "resources/org/apache/ctakes/dictionary/lookup/fast";
+ static private final String CTAKES_RES_MODULE = "ctakes-dictionary-lookup-fast-res";
+ static private final String CTAKES_RES_DB_PATH = CTAKES_RES_MODULE + "/src/main/" + CTAKES_APP_DB_PATH;
+ static private final int MIN_CHAR_LENGTH = 2;
+ static private final int MAX_CHAR_LENGTH = 50;
+ static private final int MAX_WORD_COUNT = 12;
+ static private final int MAX_SYM_COUNT = 7;
+ static private final int WSD_DIVISOR = 2;
+ static private final int ANAT_MULTIPLIER = 2;
+
+
+ private DictionaryBuilder() {
+ }
+
+
+ static boolean buildDictionary( final String umlsDirPath,
+ final String ctakesDirPath,
+ final String dictionaryName,
+ final Collection<String> wantedLanguages,
+ final Collection<String> wantedSources,
+ final Collection<String> wantedTargets,
+ final Collection<Tui> wantedTuis ) {
+ // Set up the term utility
+ final UmlsTermUtil umlsTermUtil = new UmlsTermUtil( DEFAULT_DATA_DIR );
+ final Map<Long, Concept> conceptMap
+ = parseAll( umlsTermUtil, umlsDirPath, wantedLanguages, wantedSources, wantedTargets, wantedTuis );
+ writeDatabase( ctakesDirPath, dictionaryName, conceptMap );
+ return true;
+ }
+
+
+ static private Map<Long, Concept> parseAll( final UmlsTermUtil umlsTermUtil,
+ final String umlsDirPath,
+ final Collection<String> wantedLanguages,
+ final Collection<String> wantedSources,
+ final Collection<String> wantedTargets,
+ final Collection<Tui> wantedTuis ) {
+ LOGGER.info( "Parsing Concepts" );
+ // Create a map of Cuis to empty Concepts for all wanted Tuis and source vocabularies
+ final Map<Long, Concept> conceptMap
+ = ConceptMapFactory.createInitialConceptMap( umlsDirPath, wantedTargets, wantedTuis );
+ // Fill in information for all valid concepts
+ MrconsoParser.parseAllConcepts( umlsDirPath, conceptMap, wantedSources, wantedTargets, umlsTermUtil,
+ wantedLanguages, true, MIN_CHAR_LENGTH, MAX_CHAR_LENGTH, MAX_WORD_COUNT, MAX_SYM_COUNT );
+ removeWsdRarities( conceptMap, wantedTuis, WSD_DIVISOR, ANAT_MULTIPLIER );
+// removeUnwantedDrugs( conceptMap, wantedTuis );
+ // Cull non-ANAT texts by ANAT texts as determined by ANAT tuis
+// removeAnatTexts( conceptMap, wantedTuis );
+ LOGGER.info( "Done Parsing Concepts" );
+ return conceptMap;
+ }
+
+ static private void removeWsdRarities( final Map<Long, Concept> conceptMap, final Collection<Tui> wantedTuis,
+ final int wsdDivisor, final int anatMultiplier ) {
+ LOGGER.info( "Performing Poor man's WSD ..." );
+ final Collection<Tui> wantedAnatTuis = new ArrayList<>( wantedTuis );
+ wantedAnatTuis.retainAll( Arrays.asList( TuiTableModel.CTAKES_ANAT ) );
+ final CollectionMap<String, Concept, Set<Concept>> synonymCodeMap = new HashSetMap<>( 500000 );
+ for ( Concept concept : conceptMap.values() ) {
+ concept.cullExtensions();
+ concept.getTexts().forEach( t -> synonymCodeMap.placeValue( t, concept ) );
+ }
+ // Poor man's WSD
+ for ( Map.Entry<String, Set<Concept>> synonymConcepts : synonymCodeMap ) {
+ final Collection<Concept> concepts = synonymConcepts.getValue();
+ if ( concepts.size() == 1 ) {
+ continue;
+ }
+ final String synonym = synonymConcepts.getKey();
+ int maxCount = 0;
+ for ( Concept concept : concepts ) {
+ int count = concept.getCount( synonym );
+ if ( wantedAnatTuis.containsAll( concept.getTuis() ) ) {
+ count *= anatMultiplier;
+ }
+ maxCount = Math.max( maxCount, count );
+ }
+ if ( maxCount <= 1 ) {
+ continue;
+ }
+ final int threshold = (int)Math.floor( (double)maxCount / (double)wsdDivisor );
+ for ( Concept concept : concepts ) {
+ int count = concept.getCount( synonym );
+ if ( wantedAnatTuis.containsAll( concept.getTuis() ) ) {
+ count *= anatMultiplier;
+ }
+ if ( count <= threshold ) {
+ concept.removeText( synonym );
+ }
+ }
+ }
+ final Collection<Long> empties = new ArrayList<>();
+ int textCount = 0;
+ for ( Map.Entry<Long, Concept> entry : conceptMap.entrySet() ) {
+ final Concept concept = entry.getValue();
+ if ( concept.isEmpty() ) {
+ empties.add( entry.getKey() );
+ } else {
+ textCount += concept.getSynonymCount();
+ }
+ }
+ conceptMap.keySet().removeAll( empties );
+ LOGGER.info( "Concepts: " + conceptMap.size() + " Texts: " + textCount );
+ }
+
+ static private void removeAnatTexts( final Map<Long, Concept> conceptMap,
+ final Collection<Tui> wantedTuis ) {
+ LOGGER.info( "Removing Non-Anatomy synonyms that are also Anatomy synonyms ..." );
+ final Collection<Tui> wantedAnatTuis = new ArrayList<>( wantedTuis );
+ wantedAnatTuis.retainAll( Arrays.asList( TuiTableModel.CTAKES_ANAT ) );
+ final Collection<String> anatTexts = conceptMap.values().stream()
+ .filter( c -> wantedAnatTuis.containsAll( c.getTuis() ) )
+ .map( Concept::getTexts )
+ .flatMap( Collection::stream )
+ .collect( Collectors.toSet() );
+ final Collection<Tui> nonAnatTuis = new ArrayList<>( wantedTuis );
+ nonAnatTuis.removeAll( Arrays.asList( TuiTableModel.CTAKES_ANAT ) );
+ final Collection<Long> empties = new ArrayList<>();
+ int textCount = 0;
+ for ( Map.Entry<Long, Concept> entry : conceptMap.entrySet() ) {
+ final Concept concept = entry.getValue();
+ if ( nonAnatTuis.containsAll( concept.getTuis() ) ) {
+ concept.removeTexts( anatTexts );
+ }
+ if ( concept.isEmpty() ) {
+ empties.add( entry.getKey() );
+ } else {
+ textCount += concept.getSynonymCount();
+ }
+ }
+ conceptMap.keySet().removeAll( empties );
+ LOGGER.info( "Concepts: " + conceptMap.size() + " Texts: " + textCount );
+ }
+
+
+ // TODO too much tui confusion in non-rxnorm drugs
+ static private void removeUnwantedDrugs( final Map<Long, Concept> conceptMap, Collection<Tui> wantedTuis ) {
+ LOGGER.info( "Removing Drug Concepts not in rxnorm ..." );
+ // remove concepts that have only drug tuis but are not in rxnorm
+ final Collection<Tui> drugTuis = new ArrayList<>( wantedTuis );
+ drugTuis.retainAll( Arrays.asList( TuiTableModel.CTAKES_DRUG ) );
+ // remove concepts that are in rxnorm but have non-drug tuis
+ final Collection<Tui> nonDrugTuis = new ArrayList<>( wantedTuis );
+ nonDrugTuis.removeAll( Arrays.asList( TuiTableModel.CTAKES_DRUG ) );
+ // if concept has drug tuis but is not in rxnorm || concept is in rxnorm but does not have drug tuis
+ final Collection<Long> empties = new ArrayList<>();
+ int textCount = 0;
+ for ( Map.Entry<Long, Concept> entry : conceptMap.entrySet() ) {
+ final Concept concept = entry.getValue();
+ LOGGER.info( concept.getPreferredText() );
+ if ( drugTuis.containsAll( concept.getTuis() ) && concept.getVocabularies().contains( "RXNORM" ) ) {
+ LOGGER.info( "drug" );
+ textCount += concept.getSynonymCount();
+ continue;
+ }
+ if ( nonDrugTuis.containsAll( concept.getTuis() ) && !concept.getVocabularies().contains( "RXNORM" ) ) {
+ LOGGER.info( "not drug" );
+ textCount += concept.getSynonymCount();
+ continue;
+ }
+ LOGGER.info(
+ "bad " + drugTuis.containsAll( concept.getTuis() ) + " " + nonDrugTuis.containsAll( concept.getTuis() ) +
+ " " + concept.getVocabularies().contains( "RXNORM" ) );
+ empties.add( entry.getKey() );
+ }
+ conceptMap.keySet().removeAll( empties );
+ LOGGER.info( "Concepts: " + conceptMap.size() + " Texts: " + textCount );
+ }
+
+
+ static private boolean writeDatabase( final String ctakesDirPath,
+ final String dictionaryName,
+ final Map<Long, Concept> conceptMap ) {
+ final File ctakesRoot = new File( ctakesDirPath );
+ String databaseDirPath = ctakesDirPath + "/" + CTAKES_APP_DB_PATH;
+ if ( Arrays.asList( ctakesRoot.list() ).contains( CTAKES_RES_MODULE ) ) {
+ databaseDirPath = ctakesDirPath + "/" + CTAKES_RES_DB_PATH;
+ }
+ if ( !HsqlUtil.createDatabase( databaseDirPath, dictionaryName ) ) {
+ return false;
+ }
+ if ( !DictionaryXmlWriter.writeXmlFile( databaseDirPath, dictionaryName ) ) {
+ return false;
+ }
+ final String url = HsqlUtil.URL_PREFIX + databaseDirPath.replace( '\\', '/' ) + "/" + dictionaryName + "/" +
+ dictionaryName;
+ return RareWordDbWriter.writeConcepts( conceptMap, url, "sa", "" );
+ }
+
+
+}
Added: ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/dictionary/DictionaryCreator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/dictionary/DictionaryCreator.java?rev=1788936&view=auto
==============================================================================
--- ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/dictionary/DictionaryCreator.java (added)
+++ ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/dictionary/DictionaryCreator.java Mon Mar 27 14:37:44 2017
@@ -0,0 +1,74 @@
+package org.apache.ctakes.gui.dictionary;
+
+
+import org.apache.ctakes.gui.component.DisablerPane;
+import org.apache.log4j.Logger;
+
+import javax.swing.*;
+import java.awt.*;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 12/10/2015
+ */
+final public class DictionaryCreator {
+
+ static private final Logger LOGGER = Logger.getLogger( DictionaryCreator.class );
+
+ private DictionaryCreator() {
+ }
+
+ static private JFrame createFrame() {
+ final JFrame frame = new JFrame( "cTAKES Dictionary Creator" );
+ frame.setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE );
+ // Use 1024 x 768 as the minimum required resolution (XGA)
+ // iPhone 3 : 480 x 320 (3:2, HVGA)
+ // iPhone 4 : 960 x 640 (3:2, unique to Apple)
+ // iPhone 5 : 1136 x 640 (under 16:9, unique to Apple)
+ // iPad 3&4 : 2048 x 1536 (4:3, QXGA)
+ // iPad Mini: 1024 x 768 (4:3, XGA)
+ final Dimension size = new Dimension( 800, 600 );
+ frame.setSize( size );
+ frame.setMinimumSize( size );
+ final JMenuBar menuBar = new JMenuBar();
+ final JMenu fileMenu = new JMenu( "File" );
+ menuBar.add( fileMenu );
+
+ frame.setJMenuBar( menuBar );
+ System.setProperty( "apple.laf.useScreenMenuBar", "true" );
+ return frame;
+ }
+
+ static private JComponent createMainPanel() {
+ return new MainPanel();
+ }
+
+ public static void main( final String... args ) {
+ try {
+ UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
+ UIManager.getDefaults().put( "SplitPane.border", BorderFactory.createEmptyBorder() );
+ } catch ( ClassNotFoundException | InstantiationException
+ | IllegalAccessException | UnsupportedLookAndFeelException multE ) {
+ LOGGER.error( multE.getLocalizedMessage() );
+ }
+ final JFrame frame = createFrame();
+ final JComponent mainPanel = createMainPanel();
+ frame.add( mainPanel );
+ frame.pack();
+ frame.setVisible( true );
+ DisablerPane.getInstance().initialize( frame );
+ LOGGER.info( "1. Select your Apache cTAKES root directory." );
+ LOGGER.info( " It can be a pre-built binary installation or a developer sandbox." );
+ LOGGER.info( "2. Select your Unified Medical Language System (UMLS) root directory." );
+ LOGGER.info( " Once selected, your UMLS database will be parsed for available content." );
+ LOGGER.info( "3. Select your desired Vocabulary sources in the left table." );
+ LOGGER.info( " Recommended Vocabulary sources are pre-selected." );
+ LOGGER.info( "4. Select your desired Semantic Types in the right table." );
+ LOGGER.info( " Recommended Semantic types are pre-selected." );
+ LOGGER.info( "5. Type a name for your dictionary." );
+ LOGGER.info( "6. Click \'Build Dictionary\'" );
+ LOGGER.info( "- You can resize this log panel by clicking the top and dragging up or down." );
+ }
+
+}
Added: ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/dictionary/DictionaryXmlWriter.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/dictionary/DictionaryXmlWriter.java?rev=1788936&view=auto
==============================================================================
--- ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/dictionary/DictionaryXmlWriter.java (added)
+++ ctakes/trunk/ctakes-gui/src/main/java/org/apache/ctakes/gui/dictionary/DictionaryXmlWriter.java Mon Mar 27 14:37:44 2017
@@ -0,0 +1,134 @@
+package org.apache.ctakes.gui.dictionary;
+
+
+import org.apache.ctakes.gui.dictionary.umls.VocabularyStore;
+import org.apache.log4j.Logger;
+
+import java.io.*;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 12/12/2015
+ */
+final class DictionaryXmlWriter {
+
+ static private final Logger LOGGER = Logger.getLogger( "DictionaryXmlWriter" );
+
+ private DictionaryXmlWriter() {
+ }
+
+ static boolean writeXmlFile( final String databaseDir, final String databaseName ) {
+ final File scriptFile = new File( databaseDir, databaseName + ".xml" );
+ try ( final Writer writer = new BufferedWriter( new FileWriter( scriptFile ) ) ) {
+ writer.write( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" );
+ writer.write( "<!--\n" );
+ writer.write( "Licensed to the Apache Software Foundation (ASF) under one\n" );
+ writer.write( "or more contributor license agreements. See the NOTICE file\n" );
+ writer.write( "distributed with this work for additional information\n" );
+ writer.write( "regarding copyright ownership. The ASF licenses this file\n" );
+ writer.write( "to you under the Apache License, Version 2.0 (the\n" );
+ writer.write( "\"License\"); you may not use this file except in compliance\n" );
+ writer.write( "with the License. You may obtain a copy of the License at\n" );
+ writer.write( "http://www.apache.org/licenses/LICENSE-2.0\n" );
+ writer.write( "Unless required by applicable law or agreed to in writing,\n" );
+ writer.write( "software distributed under the License is distributed on an\n" );
+ writer.write( "\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n" );
+ writer.write( "KIND, either express or implied. See the License for the\n" );
+ writer.write( "specific language governing permissions and limitations\n" );
+ writer.write( "under the License.\n" );
+ writer.write( "-->\n\n" );
+ writer.write( "<!-- New format for the .xml lookup specification. Uses table name and value type/class for Concept Factories. -->\n" );
+ writer.write( "<lookupSpecification>\n" );
+ writer.write( "<dictionaries>\n" );
+ writer.write( " <dictionary>\n" );
+ writer.write( " <name>" + databaseName + "Terms</name>\n" );
+ writer.write( " <implementationName>org.apache.ctakes.dictionary.lookup2.dictionary.UmlsJdbcRareWordDictionary</implementationName>\n" );
+ writer.write( " <properties>\n" );
+ writer.write( "<!-- urls for hsqldb memory connections must be file types in hsql 1.8.\n" );
+ writer.write( "These file urls must be either absolute path or relative to current working directory.\n" );
+ writer.write( "They cannot be based upon the classpath.\n" );
+ writer.write( "Though JdbcConnectionFactory will attempt to \"find\" a db based upon the parent dir of the url\n" );
+ writer.write( "for the sake of ide ease-of-use, the user should be aware of these hsql limitations.\n" );
+ writer.write( "-->\n" );
+ writer.write( createProperty( "jdbcDriver", "org.hsqldb.jdbcDriver" ) );
+ writer.write( createProperty( "jdbcUrl",
+ "jdbc:hsqldb:file:resources/org/apache/ctakes/dictionary/lookup/fast/" + databaseName + "/" +
+ databaseName ) );
+ writer.write( createProperty( "jdbcUser", "sa" ) );
+ writer.write( createProperty( "jdbcPass", "" ) );
+ writer.write( createProperty( "rareWordTable", "cui_terms" ) );
+ writer.write( createProperty( "umlsUrl", "https://uts-ws.nlm.nih.gov/restful/isValidUMLSUser" ) );
+ writer.write( createProperty( "umlsVendor", "NLM-6515182895" ) );
+ writer.write( createProperty( "umlsUser", "CHANGE_ME" ) );
+ writer.write( createProperty( "umlsPass", "CHANGE_ME" ) );
+ writer.write( " </properties>\n" );
+ writer.write( " </dictionary>\n" );
+ writer.write( "</dictionaries>\n" );
+ writer.write( "\n" );
+ writer.write( "<conceptFactories>\n" );
+ writer.write( " <conceptFactory>\n" );
+ writer.write( " <name>" + databaseName + "Concepts</name>\n" );
+ writer.write( " <implementationName>org.apache.ctakes.dictionary.lookup2.concept.UmlsJdbcConceptFactory</implementationName>\n" );
+ writer.write( " <properties>\n" );
+ writer.write( createProperty( "jdbcDriver", "org.hsqldb.jdbcDriver" ) );
+ writer.write( createProperty( "jdbcUrl",
+ "jdbc:hsqldb:file:resources/org/apache/ctakes/dictionary/lookup/fast/" + databaseName + "/" +
+ databaseName ) );
+ writer.write( createProperty( "jdbcUser", "sa" ) );
+ writer.write( createProperty( "jdbcPass", "" ) );
+ writer.write( createProperty( "umlsUrl", "https://uts-ws.nlm.nih.gov/restful/isValidUMLSUser" ) );
+ writer.write( createProperty( "umlsVendor", "NLM-6515182895" ) );
+ writer.write( createProperty( "umlsUser", "CHANGE_ME" ) );
+ writer.write( createProperty( "umlsPass", "CHANGE_ME" ) );
+ writer.write( createProperty( "tuiTable", "tui" ) );
+ writer.write( createProperty( "prefTermTable", "prefTerm" ) );
+ writer.write( "<!-- Optional tables for optional term info.\n" );
+ writer.write( "Uncommenting these lines alone may not persist term information;\n" );
+ writer.write( "persistence depends upon the TermConsumer. -->\n" );
+ for ( String vocabulary : VocabularyStore.getInstance().getAllVocabularies() ) {
+ writer.write( createProperty( vocabulary.toLowerCase().replace( '.', '_' ).replace( '-', '_' )
+ + "Table", VocabularyStore.getInstance().getCtakesClass( vocabulary ) ) );
+ }
+ writer.write( " </properties>\n" );
+ writer.write( " </conceptFactory>\n" );
+ writer.write( "</conceptFactories>\n" );
+ writer.write( "\n" );
+ writer.write( "<!-- Defines what terms and concepts will be used -->\n" );
+ writer.write( "<dictionaryConceptPairs>\n" );
+ writer.write( " <dictionaryConceptPair>\n" );
+ writer.write( " <name>" + databaseName + "Pair</name>\n" );
+ writer.write( " <dictionaryName>" + databaseName + "Terms</dictionaryName>\n" );
+ writer.write( " <conceptFactoryName>" + databaseName + "Concepts</conceptFactoryName>\n" );
+ writer.write( " </dictionaryConceptPair>\n" );
+ writer.write( "</dictionaryConceptPairs>\n" );
+ writer.write( "\n" );
+ writer.write( "<!-- DefaultTermConsumer will persist all spans.\n" );
+ writer.write( "PrecisionTermConsumer will only persist only the longest overlapping span of any semantic group.\n" );
+ writer.write( "SemanticCleanupTermConsumer works as Precision** but also removes signs/sympoms contained within disease/disorder,\n" );
+ writer.write( "and (just in case) removes any s/s and d/d that are also (exactly) anatomical sites. -->\n" );
+ writer.write( "<rareWordConsumer>\n" );
+ writer.write( " <name>Term Consumer</name>\n" );
+ writer.write( " <implementationName>org.apache.ctakes.dictionary.lookup2.consumer.DefaultTermConsumer</implementationName>\n" );
+ writer.write( " <!--<implementationName>org.apache.ctakes.dictionary.lookup2.consumer.PrecisionTermConsumer</implementationName>-->\n" );
+ writer.write( " <!--<implementationName>org.apache.ctakes.dictionary.lookup2.consumer.SemanticCleanupTermConsumer</implementationName>-->\n" );
+ writer.write( " <properties>\n" );
+ writer.write( "<!-- Depending upon the consumer, the value of codingScheme may or may not be used. With the packaged consumers,\n" );
+ writer.write( "codingScheme is a default value used only for cuis that do not have secondary codes (snomed, rxnorm, etc.) -->\n" );
+ writer.write( createProperty( "codingScheme", databaseName ) );
+ writer.write( " </properties>\n" );
+ writer.write( "</rareWordConsumer>\n" );
+ writer.write( "\n" );
+ writer.write( "</lookupSpecification>\n" );
+ } catch ( IOException ioE ) {
+ LOGGER.error( ioE.getMessage() );
+ return false;
+ }
+ return true;
+ }
+
+ static private String createProperty( final String name, final String value ) {
+ return " <property key=\"" + name + "\" value=\"" + value + "\"/>\n";
+ }
+
+}