Author: ruschein
Date: 2010-08-03 15:00:35 -0700 (Tue, 03 Aug 2010)
New Revision: 21154
Modified:
core3/work-swing-impl/trunk/src/main/java/org/cytoscape/work/internal/tunables/BoundedHandler.java
core3/work-swing-impl/trunk/src/main/java/org/cytoscape/work/internal/tunables/FileHandler.java
core3/work-swing-impl/trunk/src/main/java/org/cytoscape/work/internal/tunables/GuiTunableInterceptor.java
Log:
Updated to track changes in Tunable.
Modified:
core3/work-swing-impl/trunk/src/main/java/org/cytoscape/work/internal/tunables/BoundedHandler.java
===================================================================
---
core3/work-swing-impl/trunk/src/main/java/org/cytoscape/work/internal/tunables/BoundedHandler.java
2010-08-03 21:59:58 UTC (rev 21153)
+++
core3/work-swing-impl/trunk/src/main/java/org/cytoscape/work/internal/tunables/BoundedHandler.java
2010-08-03 22:00:35 UTC (rev 21154)
@@ -16,7 +16,7 @@
/**
* Handler for the type <i>Bounded</i> of <code>Tunable</code>
- *
+ *
* @author pasteur
*
* @param <T> type of <code>AbstractBounded</code>
@@ -29,36 +29,36 @@
* <code>Bounded</code> object that need to be put in this type of
<code>Guihandler</code>
*/
private T bounded;
-
+
/**
* description of the <code>Bounded</code> object that will be
displayed in the JPanel of this <code>Guihandler</code>
*/
private String title;
-
+
/**
* Representation of the <code>Bounded</code> in a <code>JSlider</code>
*/
private boolean useslider = false;
-
+
/**
* 1st representation of this <code>Bounded</code> object in its
<code>Guihandler</code>'s JPanel : a <code>JSlider</code>
*/
private mySlider slider;
-
+
/**
* 2nd representation of this <code>Bounded</code> object : a
<code>JTextField</code> that will display to the user all the informations
about the bounds
*/
private myBoundedSwing boundedField;
-
-
+
+
/**
* Construction of the <code>Guihandler</code> for the
<code>Bounded</code> type
- *
+ *
* If <code>useslider</code> is set to <code>true</code> : displays the
bounded object in a <code>JSlider</code> by using its bounds
* else diplays it in a <code>JTextField</code> with informations about
the bounds
- *
+ *
* The Swing representation is then added to the <code>JPanel</code>
for GUI representation
- *
+ *
* @param f field that has been annotated
* @param o object contained in <code>f</code>
* @param t tunable associated to <code>f</code>
@@ -68,14 +68,17 @@
try {
this.bounded = (T)f.get(o);
} catch (IllegalAccessException iae) {
- iae.printStackTrace();
+ iae.printStackTrace();
}
this.title = t.description();
- for ( Param s : t.flag())if(s.equals(Param.slider))useslider =
true;
+ for (Param s : t.flags()) {
+ if (s.equals(Param.slider))
+ useslider = true;
+ }
panel = new JPanel(new BorderLayout());
-
- try{
+
+ try {
if(useslider){
JLabel label = new JLabel(title);
label.setFont(new Font(null, Font.PLAIN,12));
@@ -84,7 +87,7 @@
slider.addChangeListener(this);
panel.add(slider,BorderLayout.EAST);
}
-
+
else{
JLabel label = new JLabel( title + " (max: " +
bounded.getLowerBound().toString() + " min: " +
bounded.getUpperBound().toString() + ")" );
label.setFont(new Font(null, Font.PLAIN,12));
@@ -92,12 +95,14 @@
panel.add(label,BorderLayout.WEST);
panel.add(boundedField,BorderLayout.EAST);
}
- }catch (Exception e) { e.printStackTrace(); }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
/**
* To set the value (from the JSlider or the JTextField) to the
<code>Bounded</code> object
- *
+ *
* The constraints of the bound values have to be respected :
<code>lowerBound < value < upperBound</code> or <code>lowerBound <i;
value <i; upperBound</code> ....
*/
public void handle() {
@@ -110,22 +115,22 @@
}
}catch (Exception e){e.printStackTrace();}
}
-
+
/**
* To get the current value of the <code>Bounded</code> object
* @return the value of the <code>Bounded</code> object
*/
- public String getState() {
- return bounded.getValue().toString();
- }
-
+ public String getState() {
+ return bounded.getValue().toString();
+ }
+
/**
* To reset the current value of this <code>BoundedHandler</code>, and
set it to the initial one
*/
@Override
- public void resetValue() {
+ public void resetValue() {
// TODO Auto-generated method stub
-
+
}
}
Modified:
core3/work-swing-impl/trunk/src/main/java/org/cytoscape/work/internal/tunables/FileHandler.java
===================================================================
---
core3/work-swing-impl/trunk/src/main/java/org/cytoscape/work/internal/tunables/FileHandler.java
2010-08-03 21:59:58 UTC (rev 21153)
+++
core3/work-swing-impl/trunk/src/main/java/org/cytoscape/work/internal/tunables/FileHandler.java
2010-08-03 22:00:35 UTC (rev 21154)
@@ -28,7 +28,7 @@
/**
* Handler for the type <i>File</i> of <code>Tunable</code>
- *
+ *
* @author pasteur
*/
public class FileHandler extends AbstractGuiHandler {
@@ -40,71 +40,73 @@
private ImageIcon image;
private JLabel titleLabel;
private JSeparator titleSeparator;
- private MouseClic mouseClic;
+ private MouseClick mouseClick;
private GroupLayout layout;
private enum Type {NETWORK,SESSION,ATTRIBUTES,DEFAULT};
- private Type type;
+ private Type type;
//private FileUtil flUtil;
-
-
+
+
/**
* Constructs the <code>Guihandler</code> for the <code>File</code> type
- *
- * It creates the GUI which displays the path of the current file in a
field, and provides access to a FileChooser with filtering parameters on
+ *
+ * It creates the GUI which displays the path of the current file in a
field, and provides access to a FileChooser with filtering parameters on
* <i>network</i>,<i>attributes</i>, or <i>session</i> (parameters are
set in the <code>Tunable</code>'s annotations of the <code>File</code>)
- *
- *
+ *
+ *
* @param f field that has been annotated
* @param o object contained in <code>f</code>
* @param t tunable associated to <code>f</code>
*/
protected FileHandler(Field f, Object o, Tunable t) {
super(f,o,t);
-// this.flUtil = flUtil;
-
+ // this.flUtil = flUtil;
+
//Construction of GUI
fileChooser = new JFileChooser();
setFileType(t);
setGui(type);
setLayout();
panel.setLayout(layout);
-
+
try{
- this.file=(File)f.get(o);
- }catch(Exception e){e.printStackTrace();}
+ this.file = (File)f.get(o);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
}
-
/**
* To set a path to the object <code>File</code> <code>o</code>
- *
+ *
* It creates a new <code>File</code> from the selected file in the
FileChooser, or from the path to a file, entered by the user in the field
- * The initial <code>File</code> object <code>o</code> is set with this
new file
+ * The initial <code>File</code> object <code>o</code> is set with this
new file
*/
public void handle() {
- try{
- f.set(o,new File(fileTextField.getText()));
- }catch(Exception e){e.printStackTrace();}
- System.out.println("File selected is : " +
fileTextField.getText());
+ try {
+ f.set(o, new File(fileTextField.getText()));
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
}
-
/**
* To reset the current file, and set it to the initial one with no path
*/
public void resetValue() {
try{
f.set(o, new File(""));
- }catch(Exception e){e.printStackTrace();}
- }
-
-
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
/**
- * To get the string representing the <code>File</code> contained in
<code>FileHandler</code> :
- *
+ * To get the string representing the <code>File</code> contained in
<code>FileHandler</code> :
+ *
* @return the representation of the object <code>o</code> contained in
<code>f</code>
*/
- public String getState() {
+ public String getState() {
String state;
try {
Object obj = f.get(o);
@@ -117,14 +119,12 @@
state = "";
}
return state;
- }
+ }
-
-
-
- //set the type of file that will be imported depending on the "Param"
Tunable annotation of the file
- private void setFileType(Tunable tunable){
- for(Param s :tunable.flag()) {
+
+ //set the type of file that will be imported depending on the "Param"
Tunable annotation of the file
+ private void setFileType(Tunable tunable) {
+ for (Param s : tunable.flags()) {
if(s.equals(Param.network)) {
type = Type.NETWORK;
return;
@@ -132,19 +132,19 @@
type = Type.SESSION;
return;
} else if(s.equals(Param.attributes)) {
- type = Type.ATTRIBUTES;
+ type = Type.ATTRIBUTES;
return;
}
}
type = Type.DEFAULT;
- }
+ }
-
- //construction of the GUI depending on the file type expected:
- // -field to display the file's path
- // -button to open the FileCHooser
- //add listener to the field and button
- private void setGui(Type type){
+
+ //construction of the GUI depending on the file type expected:
+ // -field to display the file's path
+ // -button to open the FileCHooser
+ //add listener to the field and button
+ private void setGui(Type type) {
titleSeparator = new JSeparator();
titleLabel = new JLabel();
image = new
ImageIcon(Cytoscape.class.getResource("/images/ximian/stock_open.png"));
@@ -152,130 +152,124 @@
fileTextField.setName("fileTextField");
fileTextField.setEditable(true);
fileTextField.setFont(new Font(null, Font.ITALIC,12));
- mouseClic = new MouseClic(fileTextField);
- fileTextField.addMouseListener(mouseClic);
+ mouseClick = new MouseClick(fileTextField);
+ fileTextField.addMouseListener(mouseClick);
chooseButton = new JButton("Open a File...",image);
chooseButton.setActionCommand("open");
chooseButton.addActionListener(new myFileActionListener());
-
//for each type of file : set titlelabel and fileTextField
text, and set FileChooser in order to just display files of the specified
"Param" : network,attributes,session
- switch (type){
- case NETWORK : {
- //set title and textfield text for network type
- fileTextField.setText("Please select a network
file...");
- titleLabel.setText("import network file");
-
- //set filters for filechooser
- String[] biopax = {".xml",".rdf",".owl"};
- fileChooser.addChoosableFileFilter(new
FileChooserFilter("BioPAX files",biopax));
- String[] xgmml ={".xml",".xgmml"};
- fileChooser.addChoosableFileFilter(new
FileChooserFilter("XGMML files",xgmml));
- String[] psi ={".xml"};
- fileChooser.addChoosableFileFilter(new
FileChooserFilter("PSI-MI",psi));
- String[] sif={".sif"};
- fileChooser.addChoosableFileFilter(new
FileChooserFilter("SIF files",sif));
- String[] gml={".gml"};
- fileChooser.addChoosableFileFilter(new
FileChooserFilter("GML files",gml));
- String[] sbml={".xml",".sbml"};
- fileChooser.addChoosableFileFilter(new
FileChooserFilter("SBML files",sbml));
- String[] allnetworks =
{".xml",".rdf",".owl",".xgmml",".sif",".sbml"};
- fileChooser.addChoosableFileFilter(new
FileChooserFilter("All network files (*.xml, *.rdf, *.owl, *.xgmml, *.sif,
*.sbml)",allnetworks));
- break;
- }
-
- case SESSION : {
- //set title and textfield text for session type
- fileTextField.setText("Please select a session
file...");
- titleLabel.setText("import session file");
-
- //set session filter for filechooser
- fileChooser.addChoosableFileFilter(new
FileChooserFilter("Session files (*.cys)",".cys"));
- break;
- }
-
- case ATTRIBUTES : {
- //set title and textfield text for attribute
type
- fileTextField.setText("Please select an
attributes file...");
- titleLabel.setText("import attributes file");
+ switch (type) {
+ case NETWORK : {
+ //set title and textfield text for network type
+ fileTextField.setText("Please select a network
file...");
+ titleLabel.setText("import network file");
- //set filters for filechooser
- String[] attr = {"attr","attrs"};
- fileChooser.addChoosableFileFilter(new
FileChooserFilter("Attributes files",attr));
- break;
- }
-
- default : {
- //set title and textfield text for attribute
type
- fileTextField.setText("Please select a
file...");
- titleLabel.setText("import file");
- }
+ //set filters for filechooser
+ String[] biopax = {".xml",".rdf",".owl"};
+ fileChooser.addChoosableFileFilter(new
FileChooserFilter("BioPAX files",biopax));
+ String[] xgmml ={".xml",".xgmml"};
+ fileChooser.addChoosableFileFilter(new
FileChooserFilter("XGMML files",xgmml));
+ String[] psi ={".xml"};
+ fileChooser.addChoosableFileFilter(new
FileChooserFilter("PSI-MI",psi));
+ String[] sif={".sif"};
+ fileChooser.addChoosableFileFilter(new
FileChooserFilter("SIF files",sif));
+ String[] gml={".gml"};
+ fileChooser.addChoosableFileFilter(new
FileChooserFilter("GML files",gml));
+ String[] sbml={".xml",".sbml"};
+ fileChooser.addChoosableFileFilter(new
FileChooserFilter("SBML files",sbml));
+ String[] allnetworks =
{".xml",".rdf",".owl",".xgmml",".sif",".sbml"};
+ fileChooser.addChoosableFileFilter(new
FileChooserFilter("All network files (*.xml, *.rdf, *.owl, *.xgmml, *.sif,
*.sbml)",allnetworks));
+ break;
}
- }
-
-
+ case SESSION: {
+ //set title and textfield text for session type
+ fileTextField.setText("Please select a session
file...");
+ titleLabel.setText("import session file");
+
+ //set session filter for filechooser
+ fileChooser.addChoosableFileFilter(new
FileChooserFilter("Session files (*.cys)",".cys"));
+ break;
+ }
+ case ATTRIBUTES: {
+ //set title and textfield text for attribute type
+ fileTextField.setText("Please select an attributes
file...");
+ titleLabel.setText("import attributes file");
+
+ //set filters for filechooser
+ String[] attr = {"attr","attrs"};
+ fileChooser.addChoosableFileFilter(new
FileChooserFilter("Attributes files",attr));
+ break;
+ }
+ default: {
+ //set title and textfield text for attribute type
+ fileTextField.setText("Please select a file...");
+ titleLabel.setText("import file");
+ }
+ }
+ }
+
//diplays the panel's component in a good view
- private void setLayout(){
+ private void setLayout() {
layout = new GroupLayout(panel);
-
+
layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
-
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
-
.addComponent(titleLabel,GroupLayout.PREFERRED_SIZE,350,GroupLayout.PREFERRED_SIZE)
-
.addComponent(titleSeparator,GroupLayout.DEFAULT_SIZE,350,Short.MAX_VALUE)
-
.addGroup(layout.createSequentialGroup()
-
.addComponent(fileTextField,GroupLayout.DEFAULT_SIZE,350,Short.MAX_VALUE)
-
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
-
.addComponent(chooseButton))
- )
- .addContainerGap()));
-
+
.addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
+
.addComponent(titleLabel,GroupLayout.PREFERRED_SIZE,350,GroupLayout.PREFERRED_SIZE)
+
.addComponent(titleSeparator,GroupLayout.DEFAULT_SIZE,350,Short.MAX_VALUE)
+
.addGroup(layout.createSequentialGroup()
+
.addComponent(fileTextField,GroupLayout.DEFAULT_SIZE,350,Short.MAX_VALUE)
+
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+
.addComponent(chooseButton))
+ )
+ .addContainerGap()));
+
layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(titleLabel)
- .addGap(8, 8, 8)
-
.addComponent(titleSeparator,GroupLayout.PREFERRED_SIZE,GroupLayout.DEFAULT_SIZE,GroupLayout.PREFERRED_SIZE)
- .addGap(7, 7, 7)
-
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
-
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
-
.addComponent(chooseButton)
-
.addComponent(fileTextField))
-
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED,3, Short.MAX_VALUE)
- .addContainerGap()));
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(titleLabel)
+ .addGap(8, 8, 8)
+
.addComponent(titleSeparator,GroupLayout.PREFERRED_SIZE,GroupLayout.DEFAULT_SIZE,GroupLayout.PREFERRED_SIZE)
+ .addGap(7, 7, 7)
+
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+
.addComponent(chooseButton)
+
.addComponent(fileTextField))
+
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED,3, Short.MAX_VALUE)
+ .addContainerGap()));
}
-
-
//Click on the "open" button actionlistener
- private class myFileActionListener implements ActionListener{
- public void actionPerformed(ActionEvent ae){
- if(ae.getActionCommand().equals("open")){
- int ret = fileChooser.showOpenDialog(panel);
- if (ret == JFileChooser.APPROVE_OPTION) {
- File file = fileChooser.getSelectedFile();
-// File file =
flUtil.getFile("TEST",flUtil.LOAD);
- if ( file != null ) {
- fileTextField.setFont(new Font(null,
Font.PLAIN,10));
-
fileTextField.setText(file.getAbsolutePath());
-
fileTextField.removeMouseListener(mouseClic);
- }
- }
- }
- }
- }
-
-
- //click on the field : removes its initial text
- private class MouseClic extends MouseAdapter implements MouseListener{
- JComponent component;
- public MouseClic(JComponent component) {
- this.component = component;
- }
- public void mouseClicked(MouseEvent e){
- ((JTextField)component).setText("");
- }
- }
-
+ private class myFileActionListener implements ActionListener{
+ public void actionPerformed(ActionEvent ae) {
+ if(ae.getActionCommand().equals("open")) {
+ int ret = fileChooser.showOpenDialog(panel);
+ if (ret == JFileChooser.APPROVE_OPTION) {
+ File file =
fileChooser.getSelectedFile();
+ //
File file = flUtil.getFile("TEST",flUtil.LOAD);
+ if ( file != null ) {
+ fileTextField.setFont(new
Font(null, Font.PLAIN,10));
+
fileTextField.setText(file.getAbsolutePath());
+
fileTextField.removeMouseListener(mouseClick);
+ }
+ }
+ }
+ }
+ }
+
+ //click on the field : removes its initial text
+ private class MouseClick extends MouseAdapter implements MouseListener{
+ JComponent component;
+
+ public MouseClick(JComponent component) {
+ this.component = component;
+ }
+
+ public void mouseClicked(MouseEvent e) {
+ ((JTextField)component).setText("");
+ }
+ }
+
}
Modified:
core3/work-swing-impl/trunk/src/main/java/org/cytoscape/work/internal/tunables/GuiTunableInterceptor.java
===================================================================
---
core3/work-swing-impl/trunk/src/main/java/org/cytoscape/work/internal/tunables/GuiTunableInterceptor.java
2010-08-03 21:59:58 UTC (rev 21153)
+++
core3/work-swing-impl/trunk/src/main/java/org/cytoscape/work/internal/tunables/GuiTunableInterceptor.java
2010-08-03 22:00:35 UTC (rev 21154)
@@ -138,7 +138,7 @@
Map<String,Param> groupAlignment = new
HashMap<String,Param>();
Map<String,Param> groupTitles = new
HashMap<String,Param>();
- String[] group = gh.getTunable().group();
+ String[] group = gh.getTunable().groups();
Param[] alignments =
gh.getTunable().alignment();
Param[] titles = gh.getTunable().groupTitles();
@@ -229,7 +229,7 @@
}
else {
// Figure out if the collapsable flag is set
- for (Param s : gh.getTunable().flag()) {
+ for (Param s : gh.getTunable().flags()) {
if (s.equals(Param.collapsed))
return new CollapsablePanel(title,
false);
else if (s.equals(Param.uncollapsed))
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.