Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support showing / hiding special values (suppressed and null values) #391

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 105 additions & 53 deletions src/gui/org/deidentifier/arx/gui/model/Model.java

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/gui/org/deidentifier/arx/gui/model/ModelEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ public static enum ModelPart {
RESPONSE_VARIABLES,

/** ATTRIBUTE_TYPE */
ATTRIBUTE_TYPE_BULK_UPDATE
ATTRIBUTE_TYPE_BULK_UPDATE,

/** SHOW NULL OR SUPPRESSED IN ANALYSIS */
SHOW_SPECIAL_VALUES
}

/** The part of the model that has changed. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,8 @@ StatisticsView.9=Classification models
StatisticsView.10=Classification performance
StatisticsView.12=ROC curves
StatisticsView.11=Quality models
StatisticsView.13=Include suppressed values
StatisticsView.14=Include null values
WorkerAnonymize.0=Anonymizing
WorkerAnonymize.1=Task interrupted\!
WorkerAnonymize.2=Calculating score
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 22 additions & 12 deletions src/gui/org/deidentifier/arx/gui/view/impl/utility/DensityData.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,23 @@ private void parse(Entry entry){
}

/** Width. */
private int width = -1;
private int width = -1;

/** Height. */
private int height = -1;
private int height = -1;

/** First column. */
private final int column1;
private final int column1;

/** Second column. */
private final int column2;

private final int column2;

/** Values to include */
private final boolean showSuppressedValues;

/** Values to include */
private final boolean showNullValues;

/** Statistics. */
private final StatisticsBuilder statistics;

Expand All @@ -176,23 +182,27 @@ private void parse(Entry entry){
* @param handle
* @param column1
* @param column2
* @param showSuppressedValues
* @param showNullValues
*/
public DensityData(DataHandle handle, int column1, int column2) {
public DensityData(DataHandle handle, int column1, int column2, boolean showSuppressedValues, boolean showNullValues) {
this.statistics = handle.getStatistics();
this.column1 = column1;
this.column2 = column2;
this.showSuppressedValues = showSuppressedValues;
this.showNullValues = showNullValues;
}

@Override
public JHCHeatmap getHeatmap(int width, int height) {
return new DensityHeatmap(statistics.getContingencyTable(column1, width, column2, height));
return new DensityHeatmap(statistics.getContingencyTable(column1, width, column2, height, showSuppressedValues, showNullValues));
}

@Override
public int getHeight() {
if (height == -1) {
// Perform this process when called by the background thread
this.height = statistics.getDistinctValues(column2).length;
this.height = statistics.getDistinctValues(column2, showSuppressedValues, showNullValues).length;
}
return height;
}
Expand All @@ -201,7 +211,7 @@ public int getHeight() {
public int getWidth() {
if (width == -1) {
// Perform this process when called by the background thread
this.width = statistics.getDistinctValues(column1).length;
this.width = statistics.getDistinctValues(column1, showSuppressedValues, showNullValues).length;
}
return width;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ public class LayoutUtilityStatistics implements ILayout, IView {
/** View */
private final ToolItem enable;

/** View */
private final ToolItem showSuppressed;

/** View */
private final ToolItem showNull;

/** View */
private final Image enabled;

Expand Down Expand Up @@ -114,13 +120,32 @@ public LayoutUtilityStatistics(final Composite parent,

controller.addListener(ModelPart.MODEL, this);
controller.addListener(ModelPart.SELECTED_UTILITY_VISUALIZATION, this);
controller.addListener(ModelPart.SHOW_SPECIAL_VALUES, this);

// Create enable/disable button
final String label = Resources.getMessage("StatisticsView.3"); //$NON-NLS-1$
// Create suppressed value button
final String label1 = Resources.getMessage("StatisticsView.13"); //$NON-NLS-1$
ComponentTitledFolderButtonBar bar = new ComponentTitledFolderButtonBar("id-50", helpids); //$NON-NLS-1$
bar.add(label, disabled, true, new Runnable() { @Override public void run() {
bar.add(label1, controller.getResources().getManagedImage("suppressed_value.png"), true, //$NON-NLS-1$
new Runnable() {
@Override public void run() {
toggleShowSuppressed();
}});

// Create null value button
final String label2 = Resources.getMessage("StatisticsView.14"); //$NON-NLS-1$
bar.add(label2, controller.getResources().getManagedImage("null_value.png"), true, //$NON-NLS-1$
new Runnable() {
@Override public void run() {
toggleShowNull();
}});

// Create enable/disable button
final String label3 = Resources.getMessage("StatisticsView.3"); //$NON-NLS-1$
bar.add(label3, disabled, true,
new Runnable() {
@Override public void run() {
toggleEnabled();
toggleImage();
toggleEnabledImage();
}});

// Create the tab folder
Expand All @@ -141,9 +166,13 @@ public LayoutUtilityStatistics(final Composite parent,
this.registerView(new ViewStatisticsClassificationConfiguration(folder.createItem(TAB_CLASSIFICATION_ANALYSIS, null, false, new StackLayout()), controller), "help.utility.accuracy"); //$NON-NLS-1$
}

// Init folder
// Initialize folder
this.folder.setSelection(0);
this.enable = folder.getButtonItem(label);
this.showSuppressed = folder.getButtonItem(label1);
this.showSuppressed.setEnabled(false);
this.showNull = folder.getButtonItem(label2);
this.showNull.setEnabled(false);
this.enable = folder.getButtonItem(label3);
this.enable.setEnabled(false);

// Set initial visibility
Expand Down Expand Up @@ -191,6 +220,10 @@ public void reset() {
enable.setSelection(true);
enable.setImage(enabled);
enable.setEnabled(false);
showSuppressed.setSelection(true);
showSuppressed.setEnabled(false);
showNull.setSelection(true);
showNull.setEnabled(false);
}

/**
Expand Down Expand Up @@ -229,10 +262,19 @@ public void update(ModelEvent event) {
this.model = (Model)event.data;
this.enable.setEnabled(true);
this.enable.setSelection(model.isVisualizationEnabled());
this.toggleImage();
this.toggleEnabledImage();
this.showSuppressed.setSelection(model.isShowSuppressedValues());
this.showSuppressed.setEnabled(true);
this.showNull.setSelection(model.isShowNullValues());
this.showNull.setEnabled(true);
} else if (event.part == ModelPart.SELECTED_UTILITY_VISUALIZATION) {
this.enable.setSelection(model.isVisualizationEnabled());
this.toggleImage();
this.toggleEnabledImage();
} else if (event.part == ModelPart.SHOW_SPECIAL_VALUES) {
this.showSuppressed.setSelection(model.isShowSuppressedValues());
this.showSuppressed.setEnabled(true);
this.showNull.setSelection(model.isShowNullValues());
this.showNull.setEnabled(true);
}
}

Expand Down Expand Up @@ -264,10 +306,26 @@ private void toggleEnabled() {
this.controller.update(new ModelEvent(this, ModelPart.SELECTED_UTILITY_VISUALIZATION, enable.getSelection()));
}

/**
* Toggle special values shown.
*/
private void toggleShowSuppressed() {
this.model.setShowSuppressedValues(this.showSuppressed.getSelection());
this.controller.update(new ModelEvent(this, ModelPart.SHOW_SPECIAL_VALUES, showSuppressed.getSelection()));
}

/**
* Toggle special values shown.
*/
private void toggleShowNull() {
this.model.setShowNullValues(this.showNull.getSelection());
this.controller.update(new ModelEvent(this, ModelPart.SHOW_SPECIAL_VALUES, showNull.getSelection()));
}

/**
* Toggle image.
*/
private void toggleImage(){
private void toggleEnabledImage(){
if (enable.getSelection()) {
enable.setImage(enabled);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public abstract class ViewStatistics<T extends AnalysisContextVisualization> imp
/** Parent */
private final Composite parent;

/** Needs updates to include suppressed or null*/
private final boolean dynamicallyIncludesSuppressedOrNull;

/**
* Creates a new instance.
*
Expand All @@ -80,12 +83,14 @@ public abstract class ViewStatistics<T extends AnalysisContextVisualization> imp
* @param target
* @param reset
* @param dependsOnAttribute
* @param dynamicallyIncludesSuppressedOrNull
*/
public ViewStatistics( final Composite parent,
final Controller controller,
final ModelPart target,
final ModelPart reset,
final boolean dependsOnAttribute) {
final boolean dependsOnAttribute,
final boolean dynamicallyIncludesSuppressedOrNull) {

// Register
controller.addListener(ModelPart.SELECTED_ATTRIBUTE, this);
Expand All @@ -96,6 +101,7 @@ public ViewStatistics( final Composite parent,
controller.addListener(ModelPart.DATA_TYPE, this);
controller.addListener(ModelPart.SELECTED_UTILITY_VISUALIZATION, this);
controller.addListener(ModelPart.ATTRIBUTE_VALUE, this);
controller.addListener(ModelPart.SHOW_SPECIAL_VALUES, this);
controller.addListener(target, this);
if (reset != null) {
controller.addListener(reset, this);
Expand All @@ -106,6 +112,7 @@ public ViewStatistics( final Composite parent,
this.reset = reset;
this.target = target;
this.dependsOnAttribute = dependsOnAttribute;
this.dynamicallyIncludesSuppressedOrNull = dynamicallyIncludesSuppressedOrNull;
this.parent = parent;

// Create controls
Expand Down Expand Up @@ -200,6 +207,14 @@ public void update(final ModelEvent event) {
return;
}
}

// Invalidate
if (event.part == ModelPart.SHOW_SPECIAL_VALUES) {
if (dynamicallyIncludesSuppressedOrNull) {
this.triggerUpdate();
return;
}
}

// Potentially invalidate
if (event.part == ModelPart.DATA_TYPE ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public ViewStatisticsClassification(final Composite parent,
final Controller controller,
final ModelPart part) {

super(parent, controller, part, null, false);
super(parent, controller, part, null, false, false);
this.manager = new AnalysisManager(parent.getDisplay());
this.isOutput = part != ModelPart.INPUT;
this.rocCurves = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ public class ViewStatisticsContingencyHeatmap extends ViewStatistics<AnalysisCon
* @param reset
*/
public ViewStatisticsContingencyHeatmap(final Composite parent,
final Controller controller,
final ModelPart target,
final ModelPart reset) {
final Controller controller,
final ModelPart target,
final ModelPart reset) {

super(parent, controller, target, reset, true);
super(parent, controller, target, reset, true, true);
}

@Override
Expand Down Expand Up @@ -125,12 +125,17 @@ protected void doReset() {
protected void doUpdate(AnalysisContextContingency context) {
int column1 = context.handle.getColumnIndexOf(context.attribute1);
int column2 = context.handle.getColumnIndexOf(context.attribute2);
jhc.setData(new DensityData(context.handle, column1, column2), new JHCConfiguration(context.attribute1,
context.attribute2,
MAX_SIZE,
MAX_SIZE,
gradient,
layout));
jhc.setData(new DensityData(context.handle,
column1,
column2,
context.model.isShowSuppressedValues(),
context.model.isShowNullValues()),
new JHCConfiguration(context.attribute1,
context.attribute2,
MAX_SIZE,
MAX_SIZE,
gradient,
layout));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ public class ViewStatisticsContingencyTable extends ViewStatistics<AnalysisConte
* @param reset
*/
public ViewStatisticsContingencyTable(final Composite parent,
final Controller controller,
final ModelPart target,
final ModelPart reset) {
final Controller controller,
final ModelPart target,
final ModelPart reset) {

super(parent, controller, target, reset, true);
super(parent, controller, target, reset, true, true);
this.manager = new AnalysisManager(parent.getDisplay());
}

Expand Down Expand Up @@ -184,7 +184,10 @@ public void run() throws InterruptedException {
long time = System.currentTimeMillis();

// Perform work
contingency = builder.getContingencyTable(column1, column2);
contingency = builder.getContingencyTable(column1,
column2,
context.model.isShowSuppressedValues(),
context.model.isShowNullValues());

@SuppressWarnings("unchecked")
List<Integer>[] inputValues = new List[contingency.values1.length];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public ViewStatisticsDistributionHistogram(final Composite parent,
final ModelPart target,
final ModelPart reset) {

super(parent, controller, target, reset, true);
super(parent, controller, target, reset, true, true);
this.manager = new AnalysisManager(parent.getDisplay());
}

Expand Down Expand Up @@ -344,7 +344,10 @@ public void run() throws InterruptedException {
long time = System.currentTimeMillis();

// Perform work
this.distribution = builder.getFrequencyDistribution(column, hierarchy);
this.distribution = builder.getFrequencyDistribution(column,
hierarchy,
context.model.isShowSuppressedValues(),
context.model.isShowNullValues());

// Our users are patient
while (System.currentTimeMillis() - time < MINIMAL_WORKING_TIME && !stopped){
Expand Down
Loading