Skip to content

Commit

Permalink
#17 introduce AnalysisViewSettings class for view toggles and rename …
Browse files Browse the repository at this point in the history
…SemRelation and SynItem components
  • Loading branch information
CarstenWickner committed Sep 21, 2017
1 parent 13138b0 commit 6f79ade
Show file tree
Hide file tree
Showing 15 changed files with 1,255 additions and 171 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.hmx.scitos.hmx.domain.ISemanticalRelationProvider;
import org.hmx.scitos.hmx.domain.model.AbstractConnectable;
import org.hmx.scitos.hmx.domain.model.Proposition;
import org.hmx.scitos.hmx.view.swing.components.IAnalysisViewSettings;
import org.hmx.scitos.hmx.view.swing.elements.AbstractCommentable;
import org.hmx.scitos.view.swing.IUndoManagedView;

Expand All @@ -39,18 +40,11 @@ public interface IPericopeView extends ISemanticalRelationProvider, IUndoManaged
HmxModelHandler getModelHandler();

/**
* Getter for the view preference whether the label fields of propositions should be displayed or not.
* Getter for the view preferences what parts should be displayed.
*
* @return whether to displayed proposition label fields
* @return view settings to apply
*/
boolean isShowingPropositionLabels();

/**
* Getter for the view preference whether the translation fields of propositions should be displayed or not.
*
* @return whether to displayed proposition translation fields
*/
boolean isShowingPropositionTranslations();
IAnalysisViewSettings getViewSettings();

/**
* Collect the list of selected {@link Proposition}s in the syntactical analysis, if it is currently active (i.e. displayed).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
/*
Copyright (C) 2017 HermeneutiX.org
This file is part of SciToS.
SciToS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SciToS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with SciToS. If not, see <http://www.gnu.org/licenses/>.
*/

package org.hmx.scitos.hmx.view.swing.components;

import org.hmx.scitos.hmx.core.option.HmxGeneralOption;

/**
* Collection of independent view toggles for an {@link AnalysisPanel}.
*/
class AnalysisViewSettings implements IAnalysisViewSettings {

/** Toggle: label fields of propositions. */
private boolean showingPropositionLabels;
/** Toggle: individual clause items in propositions. */
private boolean showingClauseItems;
/** Toggle: syntactic translation fields of propositions. */
private boolean showingSyntacticTranslations;
/** Toggle: semantic translation fields of propositions. */
private boolean showingSemanticTranslations;
/** Toggle: syntactic functions of propositions to other propositions. */
private boolean showingPropositionIndentations;
/** Toggle: semantic relations over propositions. */
private boolean showingRelations;

/**
* Constructor: defaulting the view toggles to the "Syntactical Analysis" preset.
*/
AnalysisViewSettings() {
this.showingPropositionLabels = HmxGeneralOption.SHOW_PROPOSITION_LABELS.getValueAsBoolean();
this.showingSyntacticTranslations = HmxGeneralOption.SHOW_PROPOSITION_TRANSLATIONS.getValueAsBoolean();
this.switchToSyntacticalAnalysis();
}

/**
* Show individual clause items and indentation functions of propostions, but hide relations and semantical translations.
*/
final void switchToSyntacticalAnalysis() {
this.showingClauseItems = true;
this.showingSyntacticTranslations = this.showingSyntacticTranslations || this.showingSemanticTranslations;
this.showingSemanticTranslations = false;
this.showingPropositionIndentations = true;
this.showingRelations = false;
}

/**
* Show relations, but hide individual clause items and indentation functions of propositions.
*/
final void switchToSemanticalAnalysis() {
this.showingClauseItems = false;
this.showingSyntacticTranslations = false;
this.showingSemanticTranslations = this.showingSyntacticTranslations || this.showingSemanticTranslations;
this.showingPropositionIndentations = false;
this.showingRelations = true;
}

/**
* Show everything.
*/
final void showAll() {
this.showingPropositionLabels = true;
this.showingClauseItems = true;
this.showingSyntacticTranslations = true;
this.showingSemanticTranslations = true;
this.showingPropositionIndentations = true;
this.showingRelations = true;
}

/**
* Hide everything but the origin text of each proposition.
*/
final void hideAll() {
this.showingPropositionLabels = false;
this.showingClauseItems = false;
this.showingSyntacticTranslations = false;
this.showingSemanticTranslations = false;
this.showingPropositionIndentations = false;
this.showingRelations = false;
}

@Override
public boolean isShowingPropositionLabels() {
return this.showingPropositionLabels;
}

/**
* Set view toggle for the label fields of propositions.
*
* @param show whether the label fields of propositions should be shown
*/
public void setShowingPropositionLabels(final boolean show) {
this.showingPropositionLabels = show;
}

@Override
public boolean isShowingClauseItems() {
return this.showingClauseItems;
}

/**
* Set view toggle for the individual clause items in propositions.
*
* @param show whether the individual clause items in propositions should be shown
*/
public void setShowingClauseItems(final boolean show) {
this.showingClauseItems = show;
}

@Override
public boolean isShowingSyntacticTranslations() {
return this.showingSyntacticTranslations;
}

/**
* Set view toggle for the syntactic translation fields of propositions.
*
* @param show whether the syntactic translation fields of propositions should be shown
*/
public void setShowingSyntacticTranslations(final boolean show) {
this.showingSyntacticTranslations = show;
}

@Override
public boolean isShowingSemanticTranslations() {
return this.showingSemanticTranslations;
}

/**
* Set view toggle for the semantic translation fields of propositions.
*
* @param show whether the semantic translation fields of propositions should be shown
*/
public void setShowingSemanticTranslations(final boolean show) {
this.showingSemanticTranslations = show;
}

@Override
public boolean isShowingPropositionIndentations() {
return this.showingPropositionIndentations;
}

/**
* Set view toggle for the syntactic functions of propositions to other propositions.
*
* @param show whether the syntactic functions of propostiions to other propositions should be shown
*/
public void setShowingPropositionIndentations(final boolean show) {
this.showingPropositionIndentations = show;
}

@Override
public boolean isShowingRelations() {
return this.showingRelations;
}

/**
* Set view toggle for the semantic relations over propositions.
*
* @param show whether the semantic relations over propositions should be shown
*/
public void setShowingRelations(final boolean show) {
this.showingRelations = show;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,9 @@ public final class CombinedAnalysesPanel extends JPanel implements IPericopeView
private final JTextPane commentArea;

/**
* Flag indicating whether the label fields of propositions should be displayed or not.
* User settings what parts of the model to display.
*/
private boolean showingPropositionLabels = HmxGeneralOption.SHOW_PROPOSITION_LABELS.getValueAsBoolean();
/**
* Flag indicating whether the translation fields of propositions should be displayed or not.
*/
private boolean showingPropositionTranslations = HmxGeneralOption.SHOW_PROPOSITION_TRANSLATIONS.getValueAsBoolean();
private final IAnalysisViewSettings viewSettings;
/**
* The most recently selected commentable model element currently associated with the {@link #commentArea}.
*/
Expand All @@ -114,10 +110,12 @@ public final class CombinedAnalysesPanel extends JPanel implements IPericopeView
* @param relationProvider
* the provider of available semantical {@link RelationTemplate}s, to be offered via the elements' context menus
*/
public CombinedAnalysesPanel(final HmxModelHandler modelHandler, final ISemanticalRelationProvider relationProvider) {
public CombinedAnalysesPanel(final HmxModelHandler modelHandler, final ISemanticalRelationProvider relationProvider,
final IAnalysisViewSettings viewSettings) {
super(new GridBagLayout());
this.modelHandler = modelHandler;
this.relationProvider = relationProvider;
this.viewSettings = viewSettings;
this.undoManager = new UndoManager<Pericope>(this.modelHandler.getModel());
this.addAncestorListener(new AncestorListener() {
@Override
Expand Down Expand Up @@ -224,6 +222,11 @@ public void actionPerformed(final ActionEvent event) {
this.add(splitArea, doubleSpan);
}

@Override
public IAnalysisViewSettings getViewSettings() {
return this.viewSettings;
}

@Override
public void modelChanged(final ModelEvent<?> event) {
// ignore change event thrown by the own undo/redo action
Expand Down Expand Up @@ -322,36 +325,6 @@ public void refresh() {
}
}

@Override
public boolean isShowingPropositionLabels() {
return this.showingPropositionLabels;
}

@Override
public boolean isShowingPropositionTranslations() {
return this.showingPropositionTranslations;
}

/**
* Toggle the visibility of the label fields for all propositions. This causes a full rebuild of the displayed Pericope.
*
* @see #refresh()
*/
public void togglePropositionLabelVisibility() {
this.showingPropositionLabels = !this.showingPropositionLabels;
this.refresh();
}

/**
* Toggle the visibility of the translation fields for all propositions. This causes a full rebuild of the displayed Pericope.
*
* @see #refresh()
*/
public void togglePropositionTranslationVisibility() {
this.showingPropositionTranslations = !this.showingPropositionTranslations;
this.refresh();
}

/**
* Determine the currently active analysis view (either {@link #synAnalysisView} or {@link #semAnalysisView}).
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
Copyright (C) 2017 HermeneutiX.org
This file is part of SciToS.
SciToS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SciToS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with SciToS. If not, see <http://www.gnu.org/licenses/>.
*/

package org.hmx.scitos.hmx.view.swing.components;

/**
* Wrapper for a number of view settings.
*/
public interface IAnalysisViewSettings {

/**
* Get view toggle for the label fields of propositions.
*
* @return whether the label fields of propositions should be shown
*/
boolean isShowingPropositionLabels();

/**
* Get view toggle for the individual clause items in propositions.
*
* @return whether the individual clause items in propositions should be shown
*/
boolean isShowingClauseItems();

/**
* Get view toggle for the syntactic translation fields of propositions.
*
* @return whether the syntactic translation fields of propositions should be shown
*/
boolean isShowingSyntacticTranslations();

/**
* Get view toggle for the semantic translation fields of propositions.
*
* @return whether the semantic translation fields of propositions should be shown
*/
boolean isShowingSemanticTranslations();

/**
* Get view toggle for the syntactic functions of propositions to other propositions.
*
* @return whether the syntactic functions of propostiions to other propositions should be shown
*/
boolean isShowingPropositionIndentations();

/**
* Get view toggle for the semantic relations over propositions.
*
* @return whether the semantic relations over propositions should be shown
*/
boolean isShowingRelations();
}
Loading

0 comments on commit 6f79ade

Please sign in to comment.