@ -161,6 +161,7 @@ public class CharacterAnalysisTab {
private HashMap < String , HashSet < String > > solarFiltersMap ;
private HostServices hostService ;
private ListChangeListener < String > taxonomyListener ;
private ChangeListener < String > calculateForListener ;
private ChangeListener < Boolean > msdListener ;
private ChangeListener < Boolean > minimalOccurrencesListener ;
private ChangeListener < Boolean > minimalTaxonomyListener ;
@ -169,6 +170,9 @@ public class CharacterAnalysisTab {
private static final String [ ] N_GRAM_COMPUTE_FOR_LETTERS_ARRAY = { "calculateFor.WORD" , "calculateFor.LOWERCASE_WORD" , "calculateFor.LEMMA" } ;
private static final ArrayList < String > N_GRAM_COMPUTE_FOR_LETTERS = new ArrayList < > ( Arrays . asList ( N_GRAM_COMPUTE_FOR_LETTERS_ARRAY ) ) ;
private static final String [ ] N_GRAM_COMPUTE_FOR_WORDS_GOS_ARRAY = { "calculateFor.WORD" , "calculateFor.LOWERCASE_WORD" , "calculateFor.LEMMA" , "calculateFor.NORMALIZED_WORD" } ;
private static final ArrayList < String > N_GRAM_COMPUTE_FOR_WORDS_GOS = new ArrayList < > ( Arrays . asList ( N_GRAM_COMPUTE_FOR_WORDS_GOS_ARRAY ) ) ;
private static final String [ ] TAXONOMY_SET_OPERATION_ARRAY = { "taxonomySetOperation.UNION" , "taxonomySetOperation.INTERSECTION" } ;
private static final ArrayList < String > TAXONOMY_SET_OPERATION = new ArrayList < > ( Arrays . asList ( TAXONOMY_SET_OPERATION_ARRAY ) ) ;
@ -184,14 +188,46 @@ public class CharacterAnalysisTab {
currentMode = MODE . LETTER ;
toggleMode ( currentMode ) ;
calculateForCB . valueProperty ( ) . addListener ( ( observable , oldValue , newValue ) - > {
if ( newValue = = null ) {
newValue = I18N . getTranslatedValue ( oldValue , N_GRAM_COMPUTE_FOR_LETTERS ) ;
calculateForCB . getSelectionModel ( ) . select ( newValue ) ;
if ( calculateForListener ! = null ) {
calculateForCB . valueProperty ( ) . removeListener ( calculateForListener ) ;
}
// calculateForCB
calculateForListener = new ChangeListener < String > ( ) {
boolean ignoreCode = false ;
@Override
public void changed ( ObservableValue < ? extends String > observable , String oldValue , String newValue ) {
if ( ignoreCode ) {
return ;
}
boolean languageChanged = newValue = = null ;
if ( languageChanged ) {
ignoreCode = true ;
if ( corpus . getCorpusType ( ) = = CorpusType . GOS ) {
newValue = I18N . getTranslatedValue ( oldValue , N_GRAM_COMPUTE_FOR_WORDS_GOS ) ;
calculateForCB . getSelectionModel ( ) . select ( newValue ) ;
} else {
newValue = I18N . getTranslatedValue ( oldValue , N_GRAM_COMPUTE_FOR_LETTERS ) ;
calculateForCB . getSelectionModel ( ) . select ( newValue ) ;
}
ignoreCode = false ;
}
calculateFor = CalculateFor . factory ( newValue ) ;
logger . info ( "calculateForCB:" , calculateFor . toString ( ) ) ;
}
calculateFor = CalculateFor . factory ( newValue ) ;
logger . info ( "calculateForCB:" , calculateFor . toString ( ) ) ;
} ) ;
} ;
calculateForCB . valueProperty ( ) . addListener ( calculateForListener ) ;
// calculateForCB.valueProperty().addListener((observable, oldValue, newValue) -> {
// if(newValue == null){
// newValue = I18N.getTranslatedValue(oldValue, N_GRAM_COMPUTE_FOR_LETTERS);
// calculateForCB.getSelectionModel().select(newValue);
// }
// calculateFor = CalculateFor.factory(newValue);
// logger.info("calculateForCB:", calculateFor.toString());
// });
calculateForCB . getSelectionModel ( ) . select ( 0 ) ;
@ -497,12 +533,19 @@ public class CharacterAnalysisTab {
stringLengthTF . setText ( String . valueOf ( stringLength ) ) ;
}
// if calculateFor was selected for something other than a word or a lemma -> reset
if ( ! ( calculateFor = = CalculateFor . WORD | | calculateFor = = CalculateFor . LEMMA | | calculateFor = = CalculateFor . LOWERCASE_WORD ) ) {
// if the user selected something else before selecting ngram for letters, reset that choice
calculateFor = CalculateFor . WORD ;
calculateForCB . getSelectionModel ( ) . select ( 0 ) ;
// // if calculateFor was selected for something other than a word or a lemma -> reset
// if (!(calculateFor == CalculateFor.WORD || calculateFor == CalculateFor.LEMMA || calculateFor == CalculateFor.LOWERCASE_WORD)) {
// // if the user selected something else before selecting ngram for letters, reset that choice
// calculateFor = CalculateFor.WORD;
//
// calculateForCB.getSelectionModel().select(0);
// }
if ( corpus . getCorpusType ( ) = = CorpusType . GOS ) {
calculateForCB . itemsProperty ( ) . unbind ( ) ;
calculateForCB . itemsProperty ( ) . bind ( I18N . createObjectBinding ( N_GRAM_COMPUTE_FOR_WORDS_GOS ) ) ;
} else {
calculateForCB . itemsProperty ( ) . unbind ( ) ;
calculateForCB . itemsProperty ( ) . bind ( I18N . createObjectBinding ( N_GRAM_COMPUTE_FOR_LETTERS ) ) ;
}
}