use of org.cytoscape.filter.internal.filters.model.CompositeFilter in project cytoscape-impl by cytoscape.
the class FilterMainPanel method initCMBFilters.
private void initCMBFilters() {
Vector<CompositeFilter> allFilters = modelLocator.getFilters();
ComboBoxModel cbm = new FilterSelectWidestStringComboBoxModel(allFilters);
cmbFilters.setModel(cbm);
cmbFilters.setRenderer(new FilterRenderer());
if (allFilters.size() == 0) {
this.btnApplyFilter.setEnabled(false);
this.btnAddFilterWidget.setEnabled(false);
}
for (CompositeFilter cf : allFilters) {
filter2SettingPanelMap.put(cf, null);
}
// Force the first filter in the model to be selected, so that it's panel will be shown
if (cbm.getSize() > 0) {
cmbFilters.setSelectedIndex(0);
}
replaceFilterSettingPanel((CompositeFilter) cmbFilters.getSelectedItem());
}
use of org.cytoscape.filter.internal.filters.model.CompositeFilter in project cytoscape-impl by cytoscape.
the class FilterMainPanel method duplicateFilter.
private void duplicateFilter() {
CompositeFilter theFilter = (CompositeFilter) cmbFilters.getSelectedItem();
String tmpName = "Copy of " + theFilter.getName();
String newFilterName = null;
while (true) {
Vector<String> nameVect = new Vector<String>();
nameVect.add(tmpName);
EditNameDialog theDialog = new EditNameDialog("Copy Filter", "Please enter a new Filter name:", nameVect, 300, 170);
theDialog.setLocationRelativeTo(this);
theDialog.setVisible(true);
newFilterName = nameVect.elementAt(0);
if ((newFilterName == null)) {
// cancel buton is clicked
return;
}
if (FilterUtil.isFilterNameDuplicated(modelLocator.getFilters(), newFilterName)) {
Object[] options = { "OK" };
JOptionPane.showOptionDialog(this, "Filter name already existed.", "Warning", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
continue;
}
break;
}
// while loop
CompositeFilter newFilter = (CompositeFilter) theFilter.clone();
newFilter.setName(newFilterName);
modelLocator.addFilter(newFilter);
FilterSettingPanel newFilterSettingPanel = new FilterSettingPanel(quickFind, this, newFilter, modelLocator, applicationManager, eventHelper);
filter2SettingPanelMap.put(newFilter, newFilterSettingPanel);
}
use of org.cytoscape.filter.internal.filters.model.CompositeFilter in project cytoscape-impl by cytoscape.
the class FilterMainPanel method createNewFilter.
private void createNewFilter(String pFilterName, String pFilterType) {
// Create an empty filter, add it to the current filter list
CompositeFilter newFilter = null;
if (pFilterType.equalsIgnoreCase("Topology")) {
newFilter = new TopologyFilter(applicationManager);
newFilter.getAdvancedSetting().setEdge(false);
newFilter.setName(pFilterName);
} else if (pFilterType.equalsIgnoreCase("NodeInteraction")) {
newFilter = new NodeInteractionFilter(applicationManager);
// newFilter.getAdvancedSetting().setEdge(false);
newFilter.setName(pFilterName);
} else if (pFilterType.equalsIgnoreCase("EdgeInteraction")) {
newFilter = new EdgeInteractionFilter(applicationManager);
// newFilter.getAdvancedSetting().setEdge(false);
newFilter.setName(pFilterName);
} else {
newFilter = new CompositeFilter(pFilterName);
}
newFilter.setNetwork(applicationManager.getCurrentNetwork());
modelLocator.addFilter(newFilter);
FilterSettingPanel newFilterSettingPanel = new FilterSettingPanel(quickFind, this, newFilter, modelLocator, applicationManager, eventHelper);
filter2SettingPanelMap.put(newFilter, newFilterSettingPanel);
if (pFilterType.equalsIgnoreCase("Composite")) {
updateCMBAttributes();
}
}
use of org.cytoscape.filter.internal.filters.model.CompositeFilter in project cytoscape-impl by cytoscape.
the class FilterReader method getInteractionFilterFromStr.
private void getInteractionFilterFromStr(InteractionFilter pFilter, List<String> pFilterStrVect, Collection<CompositeFilter> filters) {
String line = null;
for (int i = 0; i < pFilterStrVect.size(); i++) {
line = pFilterStrVect.get(i);
if (line.startsWith("name=")) {
String name = line.substring(5).trim();
pFilter.setName(name);
}
if (line.startsWith("Negation=true"))
pFilter.setNegation(true);
if (line.startsWith("Negation=false"))
pFilter.setNegation(false);
if (line.startsWith("nodeType=")) {
String nodeTypeStr = line.substring(9);
int nodeType = new Integer(nodeTypeStr).intValue();
pFilter.setNodeType(nodeType);
}
if (line.startsWith("passFilter=")) {
String name = line.substring(11).trim();
// get the reference CompositeFilter
CompositeFilter cmpFilter = null;
for (CompositeFilter cf : filters) {
if (cf.getName().equalsIgnoreCase(name)) {
cmpFilter = cf;
break;
}
}
if (cmpFilter != null) {
pFilter.setPassFilter(cmpFilter);
}
}
}
}
use of org.cytoscape.filter.internal.filters.model.CompositeFilter in project cytoscape-impl by cytoscape.
the class FilterReader method read.
public Collection<CompositeFilter> read(final File file) {
Collection<CompositeFilter> filters = null;
InputStream is = null;
try {
is = new FileInputStream(file);
filters = read(is);
} catch (FileNotFoundException fnfe) {
logger.error("Filter Read error: file not found", fnfe);
} finally {
if (is != null) {
try {
is.close();
} catch (IOException ioe) {
}
is = null;
}
}
return filters;
}
Aggregations