From 39ee30ece328bc59a1417f29b7795679f63b034b Mon Sep 17 00:00:00 2001 From: idhamari Date: Mon, 20 Dec 2021 17:48:44 +0100 Subject: [PATCH] fix issue 365 without modifing arx core --- .../arx/gui/resources/crossSR.png | Bin 0 -> 695 bytes .../arx/gui/resources/messages.properties | 3 +- .../deidentifier/arx/gui/resources/tickSR.png | Bin 0 -> 619 bytes .../async/AnalysisContextVisualization.java | 10 ++ .../view/impl/risk/AnalysisContextRisk.java | 8 + .../AnalysisContextClassification.java | 9 + .../utility/AnalysisContextContingency.java | 8 + .../utility/AnalysisContextDistribution.java | 48 +++++- .../impl/utility/AnalysisContextQuality.java | 8 + .../impl/utility/LayoutUtilityStatistics.java | 154 ++++++++++++++---- .../gui/view/impl/utility/ViewStatistics.java | 8 + .../ViewStatisticsDistributionHistogram.java | 43 ++++- .../ViewStatisticsDistributionTable.java | 26 ++- 13 files changed, 277 insertions(+), 48 deletions(-) create mode 100644 src/gui/org/deidentifier/arx/gui/resources/crossSR.png create mode 100644 src/gui/org/deidentifier/arx/gui/resources/tickSR.png diff --git a/src/gui/org/deidentifier/arx/gui/resources/crossSR.png b/src/gui/org/deidentifier/arx/gui/resources/crossSR.png new file mode 100644 index 0000000000000000000000000000000000000000..288adf8552e9299337fb82fd4cce52f65f6d899f GIT binary patch literal 695 zcmV;o0!aOdP)rn#3fXICE!QDP!nHJi8xn4x;2$fl z>+x{b!lB2udoq@lnQJuWmVyV`QrXeftB*v5jD2j>KLF@qc;?*LOb`TYxN>PQzp#-1 z8*a-^9y**8u_!kuCT`6wF3!EF{dgtAFtHdI22&?b=LXu_vwy({M{}B)Aev5dY#@7d zcSpxwDTEXNhOQg6vGa8qk4s@$_|+?#;Qz%d`eO4Bu0LOuA0`k44xv}DU45T}_Gd#lLmoF;tJP}W|%S3kk zP+-UFSA%cepLq#5sc2L$E;iV)yo;$%pRg-sm3i{WZ2G>_^nIuI`J`DX%&O|U_ed!b zQj(UkGrY>hWm4XLI9M&f}lUkkPd@RT{=VrT{?8>8VFg@grJ<;baQ6^Of7P1?tP!PLz^sHe?RcOJP)7m z^Lu_0-?0Fffp*{#-~+w@9l$t$K`)>IdM+ZDQNZ{+F@Na+3q4bPbyN`AR8x$vH zTVyQG^4`UTPio=+Ugq{N0;GXiU;&_Iz#aDb+k>t;1yyJylGCJ;X+T=60xK3G9p=(S;Vh4c!Q_Xq@Tzj2H_=$_wTE_9-z-a^RLPQ@PDbt$hbVXsnAY=rB2%AeBh#W1)z= zS>7lBkW7;7yV0Miv|6dJuSFFa@#qw(skHv&YD5;Q{*(MeLB8bha8Jf&t0JprnVFi^ zpAL`zQZ9;AYLt5}b?EztTCxVoVE(gF1Y@aD{%`qT`383X)s# dataType = null; + public DataType dataType = null; /** Context information. */ - public AttributeType attributeType = null; + public AttributeType attributeType = null; /** Context information. */ public DataHandle handle = null; @@ -47,8 +52,14 @@ public class AnalysisContextDistribution implements AnalysisContextVisualization public Model model = null; /** Context information. */ - public AnalysisContext context = null; + public AnalysisContext context = null; + /** Context distribution. */ + public String [] newDistValues = null; + + /** Context distribution. */ + public double [] newDistFreqs = null; + /** * Creates a new context from the given context. * @@ -86,4 +97,33 @@ public boolean isValid(){ else if (this.attributeType == null) return false; else return true; } + + /** + * Hide suppressed records. + * + * @param distribution + * @throws InterruptedException + */ + public void hideSuppressedData( StatisticsFrequencyDistribution distribution) throws InterruptedException { + + ArrayList newValues = new ArrayList(); + for (String s: distribution.values) { + newValues.add(s); + } + double srSum = 0.0; + int sr=newValues.indexOf("*"); + newValues.removeIf(element-> (element=="*")); + + for (int i = 0; i helpids = new HashMap(); @@ -108,28 +126,53 @@ public LayoutUtilityStatistics(final Composite parent, final ModelPart target, final ModelPart reset) { - this.enabled = controller.getResources().getManagedImage("tick.png"); //$NON-NLS-1$ - this.disabled = controller.getResources().getManagedImage("cross.png"); //$NON-NLS-1$ + // initialize controller components + + // initialize check button icons + this.icnVisEnabled = controller.getResources().getManagedImage("tick.png"); //$NON-NLS-1$ + this.icnVisDisabled = controller.getResources().getManagedImage("cross.png"); //$NON-NLS-1$ + + this.icnSREnabled = controller.getResources().getManagedImage("tickSR.png"); //$NON-NLS-1$ + this.icnSRDisabled = controller.getResources().getManagedImage("crossSR.png"); //$NON-NLS-1$ + this.controller = controller; controller.addListener(ModelPart.MODEL, this); controller.addListener(ModelPart.SELECTED_UTILITY_VISUALIZATION, this); - // Create enable/disable button - final String label = Resources.getMessage("StatisticsView.3"); //$NON-NLS-1$ - ComponentTitledFolderButtonBar bar = new ComponentTitledFolderButtonBar("id-50", helpids); //$NON-NLS-1$ - bar.add(label, disabled, true, new Runnable() { @Override public void run() { - toggleEnabled(); - toggleImage(); + // Create toolbar + ComponentTitledFolderButtonBar toolbarVis = new ComponentTitledFolderButtonBar("id-50", helpids); //$NON-NLS-1$ + + // Create suppressed records and visualisation enable/disable check buttons + final String chkbtnSuppressedRecordsLabel = Resources.getMessage("StatisticsView.13"); //$NON-NLS-1$ + final String chkbtnVisualisationLabel = Resources.getMessage("StatisticsView.3"); //$NON-NLS-1$ + + + // add check buttons to the to the toolbar + + if (!(target == ModelPart.INPUT)) { + toolbarVis.add(chkbtnSuppressedRecordsLabel, icnSRDisabled, true, new Runnable() { @Override public void run() { + toggleChkbtnSuppressedRecords(); + toggleChkbtnSRIcon(); + }}); + } + + toolbarVis.add(chkbtnVisualisationLabel, icnVisDisabled, true, new Runnable() { @Override public void run() { + toggleChkbtnVisualization(); + toggleChkbtnVizIcon(); }}); + // Create the tab folder - folder = new ComponentTitledFolder(parent, controller, bar, null, false, true); + folder = new ComponentTitledFolder(parent, controller, toolbarVis, null, false, true); + distHist = new ViewStatisticsDistributionHistogram(folder.createItem(TAB_DISTRIBUTION, null, true), controller, target, reset ); + distTbl = new ViewStatisticsDistributionTable(folder.createItem(TAB_DISTRIBUTION_TABLE, null, true), controller, target, reset); + // Register tabs this.registerView(new ViewStatisticsSummaryTable(folder.createItem(TAB_SUMMARY, null, true), controller, target, reset), "help.utility.summary"); //$NON-NLS-1$ - this.registerView(new ViewStatisticsDistributionHistogram(folder.createItem(TAB_DISTRIBUTION, null, true), controller, target, reset), "help.utility.distribution"); //$NON-NLS-1$ - this.registerView(new ViewStatisticsDistributionTable(folder.createItem(TAB_DISTRIBUTION_TABLE, null, true), controller, target, reset), "help.utility.distribution"); //$NON-NLS-1$ + this.registerView( distHist, "help.utility.distribution"); //$NON-NLS-1$ + this.registerView( distTbl , "help.utility.distribution"); //$NON-NLS-1$ this.registerView(new ViewStatisticsContingencyHeatmap(folder.createItem(TAB_CONTINGENCY, null, true), controller, target, reset), "help.utility.contingency"); //$NON-NLS-1$ this.registerView(new ViewStatisticsContingencyTable(folder.createItem(TAB_CONTINGENCY_TABLE, null, true), controller, target, reset), "help.utility.contingency"); //$NON-NLS-1$ this.registerView(new ViewStatisticsEquivalenceClassTable(folder.createItem(TAB_CLASSES_TABLE, null, true), controller, target, reset), "help.utility.classes"); //$NON-NLS-1$ @@ -143,12 +186,21 @@ public LayoutUtilityStatistics(final Composite parent, // Init folder this.folder.setSelection(0); - this.enable = folder.getButtonItem(label); - this.enable.setEnabled(false); + this.chkbtnVisualisation = folder.getButtonItem(chkbtnVisualisationLabel); + this.chkbtnVisualisation.setEnabled(false); + this.chkbtnVisualisation.setToolTipText("Disable visualization!"); + + if ( !(target == ModelPart.INPUT) ) { + this.chkbtnSuppressedRecords = folder.getButtonItem(chkbtnSuppressedRecordsLabel); + this.chkbtnSuppressedRecords.setEnabled(true); + this.chkbtnSuppressedRecords.setToolTipText("Hide suppressed records!"); + + }; // Set initial visibility folder.setVisibleItems(Arrays.asList(new String[] { TAB_SUMMARY, TAB_DISTRIBUTION, + TAB_DISTRIBUTION_TABLE, TAB_CONTINGENCY, TAB_CLASSES_TABLE, TAB_PROPERTIES })); @@ -188,9 +240,9 @@ public List getVisibleItems() { @Override public void reset() { model = null; - enable.setSelection(true); - enable.setImage(enabled); - enable.setEnabled(false); + chkbtnVisualisation.setSelection(true); + chkbtnVisualisation.setImage(icnVisEnabled); + chkbtnVisualisation.setEnabled(false); } /** @@ -227,13 +279,12 @@ public void update(ModelEvent event) { if (event.part == ModelPart.MODEL) { this.model = (Model)event.data; - this.enable.setEnabled(true); - this.enable.setSelection(model.isVisualizationEnabled()); - this.toggleImage(); + this.chkbtnVisualisation.setEnabled(true); + this.chkbtnVisualisation.setSelection(model.isVisualizationEnabled()); } else if (event.part == ModelPart.SELECTED_UTILITY_VISUALIZATION) { - this.enable.setSelection(model.isVisualizationEnabled()); - this.toggleImage(); + this.chkbtnVisualisation.setSelection(model.isVisualizationEnabled()); } + this.toggleChkbtnVizIcon(); } /** @@ -259,19 +310,56 @@ private void registerView(ViewStatisticsBasic view, String helpid) { /** * Toggle visualization enabled. */ - private void toggleEnabled() { - this.model.setVisualizationEnabled(this.enable.getSelection()); - this.controller.update(new ModelEvent(this, ModelPart.SELECTED_UTILITY_VISUALIZATION, enable.getSelection())); + /** + * Toggle visualization . + */ + private void toggleChkbtnVisualization() { + this.model.setVisualizationEnabled(this.chkbtnVisualisation.getSelection()); + this.controller.update(new ModelEvent(this, ModelPart.SELECTED_UTILITY_VISUALIZATION, chkbtnVisualisation.getSelection())); } /** - * Toggle image. + * Toggle suppressed records */ - private void toggleImage(){ - if (enable.getSelection()) { - enable.setImage(enabled); - } else { - enable.setImage(disabled); + private void toggleChkbtnSuppressedRecords() { + if (this.chkbtnVisualisation.getSelection()) { + this.hideSuppressedRecords = this.chkbtnSuppressedRecords.getSelection(); + + this.model.setVisualizationEnabled(false); + this.controller.update(new ModelEvent(this, ModelPart.SELECTED_UTILITY_VISUALIZATION, false)); + + this.distHist.update(new ModelEvent(this, ModelPart.SELECTED_UTILITY_VISUALIZATION, false),this.hideSuppressedRecords); + this.distTbl.update(new ModelEvent(this, ModelPart.SELECTED_UTILITY_VISUALIZATION, false),this.hideSuppressedRecords); + + this.model.setVisualizationEnabled(true); + this.controller.update(new ModelEvent(this, ModelPart.SELECTED_UTILITY_VISUALIZATION, true)); } } + + + /** + * Toggle check button image. + */ + private void toggleChkbtnVizIcon(){ + if (!this.chkbtnVisualisation.getSelection()) { + this.chkbtnVisualisation.setImage(icnVisDisabled); + this.chkbtnVisualisation.setToolTipText("Enable visualization!"); + } else { + this.chkbtnVisualisation.setImage(icnVisEnabled); + this.chkbtnVisualisation.setToolTipText("Disable visualization!"); + } + } + + /** + * Toggle check button image. + */ + private void toggleChkbtnSRIcon(){ + if (!this.chkbtnSuppressedRecords.getSelection()) { + this.chkbtnSuppressedRecords.setImage(icnSRDisabled); + this.chkbtnSuppressedRecords.setToolTipText("Hide suppressed records!"); + } else { + this.chkbtnSuppressedRecords.setImage(icnSREnabled); + this.chkbtnSuppressedRecords.setToolTipText("View suppressed records!"); + } + } } diff --git a/src/gui/org/deidentifier/arx/gui/view/impl/utility/ViewStatistics.java b/src/gui/org/deidentifier/arx/gui/view/impl/utility/ViewStatistics.java index 9699762a11..c94cb0079a 100644 --- a/src/gui/org/deidentifier/arx/gui/view/impl/utility/ViewStatistics.java +++ b/src/gui/org/deidentifier/arx/gui/view/impl/utility/ViewStatistics.java @@ -386,4 +386,12 @@ protected void setStatusEmpty(){ protected void setStatusWorking(){ this.status.setWorking(); } + + /** + * Status working. + */ + public void update(ModelEvent event, Boolean hideSuppressedRecords) { + // TODO Auto-generated method stub + + } } diff --git a/src/gui/org/deidentifier/arx/gui/view/impl/utility/ViewStatisticsDistributionHistogram.java b/src/gui/org/deidentifier/arx/gui/view/impl/utility/ViewStatisticsDistributionHistogram.java index e56bb0d789..8820c336a5 100644 --- a/src/gui/org/deidentifier/arx/gui/view/impl/utility/ViewStatisticsDistributionHistogram.java +++ b/src/gui/org/deidentifier/arx/gui/view/impl/utility/ViewStatisticsDistributionHistogram.java @@ -21,6 +21,7 @@ import org.deidentifier.arx.aggregates.StatisticsBuilderInterruptible; import org.deidentifier.arx.aggregates.StatisticsFrequencyDistribution; import org.deidentifier.arx.gui.Controller; +import org.deidentifier.arx.gui.model.ModelEvent; import org.deidentifier.arx.gui.model.ModelEvent.ModelPart; import org.deidentifier.arx.gui.resources.Resources; import org.deidentifier.arx.gui.view.SWTUtil; @@ -72,6 +73,9 @@ public class ViewStatisticsDistributionHistogram extends ViewStatistics