Skip to content

Commit 310d173

Browse files
committed
fixed issue #109 Display panel retained pointer to auto annotate object even after delete.
1 parent 167c419 commit 310d173

File tree

4 files changed

+37
-13
lines changed

4 files changed

+37
-13
lines changed

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/autoannotate/AutoAnnotationManager.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,5 +293,14 @@ public void setClusterTableUpdating(boolean clusterTableUpdating) {
293293
this.clusterTableUpdating = clusterTableUpdating;
294294
}
295295

296-
296+
public AutoAnnotationParameters getParams(){
297+
//get the current View
298+
CyNetworkView selectedView = this.annotationPanel.getCurrentView();
299+
300+
if (networkViewToAutoAnnotationParameters.containsKey(selectedView))
301+
302+
return networkViewToAutoAnnotationParameters.get(selectedView);
303+
else
304+
return null;
305+
}
297306
}

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/autoannotate/task/cluster/DrawClusterLabelTask.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ public void drawTextLabel() {
3939
// Set the text of the label
4040
String labelText = cluster.getLabel();
4141

42-
Map<String, String> ellipseArgs = cluster.getEllipse().getArgMap();
43-
double xPos = Double.parseDouble(ellipseArgs.get("x"));
44-
double yPos = Double.parseDouble(ellipseArgs.get("y"));
45-
double width = Double.parseDouble(ellipseArgs.get("width"));
46-
double height = Double.parseDouble(ellipseArgs.get("height"));
47-
42+
double xPos= 0.0,yPos= 0.0,width= 0.0,height = 0.0;
43+
if(cluster.getEllipse() != null){
44+
Map<String, String> ellipseArgs = cluster.getEllipse().getArgMap();
45+
xPos = Double.parseDouble(ellipseArgs.get("x"));
46+
yPos = Double.parseDouble(ellipseArgs.get("y"));
47+
width = Double.parseDouble(ellipseArgs.get("width"));
48+
height = Double.parseDouble(ellipseArgs.get("height"));
49+
}
4850
// Create the text annotation
4951
Integer labelFontSize = null;
5052
if (constantFontSize) {

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/autoannotate/view/AutoAnnotationPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,8 @@ public void itemStateChanged(ItemEvent itemEvent) {
430430
CyGroupFactory groupFactory = autoAnnotationManager.getGroupFactory();
431431
if (itemEvent.getStateChange() == ItemEvent.SELECTED) {
432432
AnnotationSet annotationSet = (AnnotationSet) itemEvent.getItem();
433-
displayOptionsPanel.setSelectedAnnotationSet(annotationSet);
434433
params.setSelectedAnnotationSet(annotationSet);
434+
displayOptionsPanel.setSelectedAnnotationSet();
435435
// Update the selected annotation set
436436
annotationSet.updateCoordinates();
437437
String annotationSetName = annotationSet.getName();

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/autoannotate/view/DisplayOptionsPanel.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class DisplayOptionsPanel extends JPanel implements CytoPanelComponent {
4747
private JCheckBox showEllipsesCheckBox;
4848
private JRadioButton heatmapButton;
4949
protected JPanel slidersPanel;
50-
50+
5151
private static String proportionalSizeButtonString = "Font size by # of nodes";
5252
private static String constantSizeButtonString = "Constant font size";
5353

@@ -116,8 +116,11 @@ public void actionPerformed(ActionEvent e) {
116116
if (fontSize <= 0) {
117117
throw new Exception();
118118
}
119-
selectedAnnotationSet.setFontSize(fontSize);
120-
AutoAnnotationUtils.updateFontSizes();
119+
setSelectedAnnotationSet();
120+
if(selectedAnnotationSet != null){
121+
selectedAnnotationSet.setFontSize(fontSize);
122+
AutoAnnotationUtils.updateFontSizes();
123+
}
121124
} catch (Exception ex) {
122125
JOptionPane.showMessageDialog(null,
123126
"Error: Please enter an integer bigger than 0", "Error Message",
@@ -169,6 +172,9 @@ private JPanel createShowAnnotationsCheckBoxPanel() {
169172
showEllipsesCheckBox.addActionListener(new ActionListener() {
170173
@Override
171174
public void actionPerformed(ActionEvent e) {
175+
//make sure we are working with the current selected network
176+
setSelectedAnnotationSet();
177+
172178
if (selectedAnnotationSet != null) {
173179
selectedAnnotationSet.setShowEllipses(showEllipsesCheckBox.isSelected());
174180
if (selectedAnnotationSet.isShowEllipses()) {
@@ -195,6 +201,9 @@ public void actionPerformed(ActionEvent e) {
195201
showTextCheckBox.addActionListener(new ActionListener() {
196202
@Override
197203
public void actionPerformed(ActionEvent e) {
204+
//make sure we are working with the current selected network
205+
setSelectedAnnotationSet();
206+
198207
if (selectedAnnotationSet != null) {
199208
JCheckBox showTextCheckBox = (JCheckBox) e.getSource();
200209
selectedAnnotationSet.setShowLabel(showTextCheckBox.isSelected());
@@ -228,6 +237,9 @@ private JPanel createLabelOptionsButtonPanel() {
228237
labelOptionsButton.addActionListener(new ActionListener() {
229238
@Override
230239
public void actionPerformed(ActionEvent e) {
240+
//make sure we are working with the current selected network
241+
setSelectedAnnotationSet();
242+
231243
if (selectedAnnotationSet != null) {
232244
LabelOptionsEditor labelOptionsEditor = new LabelOptionsEditor(selectedAnnotationSet);
233245
LabelOptions labelOptions = labelOptionsEditor.showDialog();
@@ -384,7 +396,8 @@ public String getTitle() {
384396
return "Annotation Display Options Panel";
385397
}
386398

387-
public void setSelectedAnnotationSet(AnnotationSet selectedAnnotationSet) {
388-
this.selectedAnnotationSet = selectedAnnotationSet;
399+
public void setSelectedAnnotationSet() {
400+
this.selectedAnnotationSet = AutoAnnotationManager.getInstance().getParams().getSelectedAnnotationSet();
401+
389402
}
390403
}

0 commit comments

Comments
 (0)