Author: neildhruva
Date: 2012-07-16 09:37:40 -0700 (Mon, 16 Jul 2012)
New Revision: 29907
Added:
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/ChartAppFactoryImpl.java
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/PanelLayout.java
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/impl/ChartAppFactory.java
Modified:
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/CyActivator.java
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/EventTableAdded.java
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/EventTableDestroyed.java
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/MyCytoPanel.java
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/PanelComponents.java
Log:
The ChartAppFactory.java interface in exported as a service. It is also
imported and subsequently used in the app. ChartAppFactoryImpl.java is the
implementation of this interface. Changes are made to other files in order to
implement this method (of export and import of services).
Added:
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/ChartAppFactoryImpl.java
===================================================================
---
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/ChartAppFactoryImpl.java
(rev 0)
+++
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/ChartAppFactoryImpl.java
2012-07-16 16:37:40 UTC (rev 29907)
@@ -0,0 +1,91 @@
+package org.cytoscape.neildhruva.chartapp;
+
+import java.util.ArrayList;
+
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JPanel;
+import javax.swing.JTable;
+
+import org.cytoscape.model.CyIdentifiable;
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNetworkTableManager;
+import org.cytoscape.model.CyRow;
+import org.cytoscape.model.CyTable;
+import org.cytoscape.model.CyTableFactory;
+import org.cytoscape.model.CyTableManager;
+import org.cytoscape.neildhruva.chartapp.impl.ChartAppFactory;
+
+public class ChartAppFactoryImpl implements ChartAppFactory {
+
+ private JPanel jpanel;
+ private int tableColumnCount;
+ private CyTableFactory tableFactory;
+ private CyNetworkTableManager cyNetworkTableMgr;
+ private CyTableManager cyTableManager;
+ private PanelComponents panelComponents;
+ private PanelLayout panelLayout;
+
+ public ChartAppFactoryImpl( CyTableFactory tableFactory,
+
CyNetworkTableManager cyNetworkTableMgr,
+ CyTableManager
cyTableManager) {
+
+ this.tableFactory = tableFactory;
+ this.cyNetworkTableMgr = cyNetworkTableMgr;
+ this.cyTableManager = cyTableManager;
+ this.panelLayout = new PanelLayout();
+ this.panelComponents = new PanelComponents(panelLayout);
+ }
+
+ public JPanel createPanel(CyNetwork currentNetwork, CyTable cyTable) {
+
+ final Long networkSUID = currentNetwork.getSUID();
+ JTable table = new JTable(new MyTableModel(cyTable));
+ tableColumnCount = table.getColumnCount();
+
+ //myCyTable is the custom CyTable created for this app and
associated with each network.
+ CyTable myCyTable=null;
+
+ myCyTable = cyNetworkTableMgr.getTable(currentNetwork,
CyNetwork.class, "PrintTable "+cyTable.getTitle());
+
+ if(myCyTable!=null) {
+ panelComponents.initComponents(myCyTable, cyTable);
+ } else {
+ //checkBoxState stores information on whether a given
column of a network table is
+ //hidden or visible depending on the associated boolean
value (true for visible)
+ ArrayList<Boolean> checkBoxState = new
ArrayList<Boolean>();
+ ArrayList<String> columnNamesList = new
ArrayList<String>();
+ for(int i=0; i<tableColumnCount; i++) {
+ columnNamesList.add(table.getColumnName(i));
+ checkBoxState.add(true);
+ }
+
+ //if myCyTable is null, create a new CyTable and
associate it with the current network.
+ myCyTable = tableFactory.createTable("PrintTable
"+cyTable.getTitle(), CyIdentifiable.SUID, Long.class, true, true);
+ myCyTable.createListColumn("Names", String.class, true);
+ myCyTable.createListColumn("States", Boolean.class,
true);
+ myCyTable.createColumn("ChartType", String.class, true);
+
+ CyRow cyrow = myCyTable.getRow(networkSUID);
+ cyrow.set("Names", columnNamesList);
+ cyrow.set("States", checkBoxState);
+ cyrow.set("ChartType", "Bar Chart"); //default value is
"Bar Chart"
+
+ //associate myCyTable with this network
+ cyNetworkTableMgr.setTable(currentNetwork,
CyNetwork.class, "PrintTable "+cyTable.getTitle(), myCyTable);
+ //add myCyTable to the CyTableManager in order to
preserve it across sessions
+ cyTableManager.addTable(myCyTable);
+
+ panelComponents.initComponents(myCyTable, cyTable);
+ }
+
+ JComboBox chartTypeComboBox = panelComponents.getComboBox();
+ table = panelComponents.getTable();
+ JCheckBox[] checkBoxArray = panelComponents.getCheckBoxArray();
+ jpanel = panelLayout.initLayout(table, tableColumnCount,
checkBoxArray, chartTypeComboBox);
+
+ return jpanel;
+ }
+
+
+}
Modified:
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/CyActivator.java
===================================================================
---
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/CyActivator.java
2012-07-16 15:53:00 UTC (rev 29906)
+++
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/CyActivator.java
2012-07-16 16:37:40 UTC (rev 29907)
@@ -6,6 +6,7 @@
import org.cytoscape.model.CyTableFactory;
import org.cytoscape.model.CyTableManager;
import org.cytoscape.model.events.NetworkAboutToBeDestroyedListener;
+import org.cytoscape.neildhruva.chartapp.impl.ChartAppFactory;
import org.cytoscape.service.util.AbstractCyActivator;
import org.osgi.framework.BundleContext;
import java.util.Properties;
@@ -24,12 +25,17 @@
CyTableManager cyTableManagerServiceRef =
getService(bc,CyTableManager.class);
MyCytoPanel myCytoPanel = new MyCytoPanel();
- EventTableAdded tableAddedEvent = new
EventTableAdded(myCytoPanel, cyDataTableFactoryServiceRef,
cyNetworkTableManagerServiceRef, cyTableManagerServiceRef);
- EventTableDestroyed tableDestroyedEvent = new
EventTableDestroyed(myCytoPanel);
+ ChartAppFactoryImpl chartAppFactoryImpl = new
ChartAppFactoryImpl(cyDataTableFactoryServiceRef,
cyNetworkTableManagerServiceRef, cyTableManagerServiceRef);
+ registerService(bc, chartAppFactoryImpl, ChartAppFactory.class,
new Properties());
+ ChartAppFactory chartAppFactory = getService(bc,
ChartAppFactory.class);
+
+ EventTableAdded eventTableAdded = new
EventTableAdded(myCytoPanel, chartAppFactory);
+ EventTableDestroyed eventTableDestroyed = new
EventTableDestroyed(myCytoPanel);
+
registerService(bc,myCytoPanel,CytoPanelComponent.class, new
Properties());
-
registerService(bc,tableAddedEvent,SetCurrentNetworkListener.class, new
Properties());
-
registerService(bc,tableDestroyedEvent,NetworkAboutToBeDestroyedListener.class,
new Properties());
+
registerService(bc,eventTableAdded,SetCurrentNetworkListener.class, new
Properties());
+
registerService(bc,eventTableDestroyed,NetworkAboutToBeDestroyedListener.class,
new Properties());
}
Modified:
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/EventTableAdded.java
===================================================================
---
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/EventTableAdded.java
2012-07-16 15:53:00 UTC (rev 29906)
+++
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/EventTableAdded.java
2012-07-16 16:37:40 UTC (rev 29907)
@@ -2,10 +2,10 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.Iterator;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
+import javax.swing.JPanel;
import javax.swing.JTable;
import org.cytoscape.application.events.SetCurrentNetworkEvent;
@@ -17,88 +17,31 @@
import org.cytoscape.model.CyTable;
import org.cytoscape.model.CyTableFactory;
import org.cytoscape.model.CyTableManager;
+import org.cytoscape.neildhruva.chartapp.impl.ChartAppFactory;
public class EventTableAdded implements SetCurrentNetworkListener{
private MyCytoPanel myCytoPanel;
- private JTable table;
- private JCheckBox[] checkBoxArray;
- private PanelComponents panelComponents=null;
- private int columnCount;
- private List<Boolean> checkBoxState;
- private List<String> columnNamesList;
- private CyTableFactory tableFactory;
- private CyTableManager cyTableManager;
- private CyNetworkTableManager cyNetworkTableMgr;
- private JComboBox chartTypeComboBox;
+ private ChartAppFactory chartAppFactory;
- EventTableAdded(MyCytoPanel myCytoPanel,
- CyTableFactory tableFactory,
- CyNetworkTableManager cyNetworkTableMgr,
- CyTableManager cyTableManager) {
-
+ EventTableAdded(MyCytoPanel myCytoPanel, ChartAppFactory
chartAppFactory) {
this.myCytoPanel = myCytoPanel;
- this.tableFactory = tableFactory;
- this.cyNetworkTableMgr = cyNetworkTableMgr;
- this.cyTableManager = cyTableManager;
- this.panelComponents = new PanelComponents(myCytoPanel);
+ this.chartAppFactory = chartAppFactory;
}
-
@Override
public void handleEvent(SetCurrentNetworkEvent e) {
- if(e.getNetwork() == null)
+ final CyNetwork cyNetwork = e.getNetwork();
+ if(cyNetwork == null)
return;
- //cytable is the CyTable corresponding to the current node table
- final CyTable cytable = e.getNetwork().getDefaultNodeTable();
- if(cytable==null)
+ //cyTable is the CyTable corresponding to the current node table
+ final CyTable cyTable = e.getNetwork().getDefaultNodeTable();
+ if(cyTable==null)
return;
- final Long networkSUID = e.getNetwork().getSUID();
- table = new JTable(new MyTableModel(cytable));
- columnCount = table.getColumnCount();
-
- //myCyTable is the custom CyTable created for this app and
associated with each network.
- CyTable myCyTable=null;
-
- myCyTable = cyNetworkTableMgr.getTable(e.getNetwork(),
CyNetwork.class, "PrintTable");
-
- if(myCyTable!=null) {
- panelComponents.initCheckBoxArray(myCyTable, cytable);
- } else {
- //checkBoxState stores information on whether a given
column of a network table is
- //hidden or visible depending on the associated boolean
value (true for visible)
- checkBoxState = new ArrayList<Boolean>();
- columnNamesList = new ArrayList<String>();
- for(int i=0; i<columnCount; i++) {
- columnNamesList.add(table.getColumnName(i));
- checkBoxState.add(true);
- }
-
- //if myCyTable is null, create a new CyTable and
associate it with the current network.
- myCyTable = tableFactory.createTable("PrintTable
"+cytable.getTitle(), CyIdentifiable.SUID, Long.class, true, true);
- myCyTable.createListColumn("Names", String.class, true);
- myCyTable.createListColumn("States", Boolean.class,
true);
- myCyTable.createColumn("ChartType", String.class, true);
-
- CyRow cyrow = myCyTable.getRow(networkSUID);
- cyrow.set("Names", columnNamesList);
- cyrow.set("States", checkBoxState);
- cyrow.set("ChartType", "Bar Chart"); //default value is
"Bar Chart"
-
- //associate myCyTable with this network
- cyNetworkTableMgr.setTable(e.getNetwork(),
CyNetwork.class, "PrintTable", myCyTable);
- //add myCyTable to the CyTableManager in order to
preserve it across sessions
- cyTableManager.addTable(myCyTable);
-
- panelComponents.initCheckBoxArray(myCyTable, cytable);
- }
-
- chartTypeComboBox = panelComponents.getComboBox();
- table = panelComponents.getTable();
- checkBoxArray = panelComponents.getCheckBoxArray();
- myCytoPanel.initComponents(table, checkBoxArray, columnCount,
chartTypeComboBox);
+ JPanel jpanel = chartAppFactory.createPanel(cyNetwork, cyTable);
+ myCytoPanel.setJPanel(jpanel);
}
}
Modified:
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/EventTableDestroyed.java
===================================================================
---
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/EventTableDestroyed.java
2012-07-16 15:53:00 UTC (rev 29906)
+++
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/EventTableDestroyed.java
2012-07-16 16:37:40 UTC (rev 29907)
@@ -3,6 +3,7 @@
import java.awt.GridLayout;
import javax.swing.JLabel;
+import javax.swing.JPanel;
import org.cytoscape.model.events.NetworkAboutToBeDestroyedEvent;
import org.cytoscape.model.events.NetworkAboutToBeDestroyedListener;
@@ -11,7 +12,6 @@
private MyCytoPanel myCytoPanel;
-
EventTableDestroyed(MyCytoPanel myCytoPanel){
this.myCytoPanel = myCytoPanel;
}
@@ -19,11 +19,11 @@
@Override
public void handleEvent(NetworkAboutToBeDestroyedEvent e) {
- //Clear the Table View Panel
- myCytoPanel.removeAll();
JLabel label = new JLabel("Please select/import a network");
- myCytoPanel.setLayout(new GridLayout());
- myCytoPanel.add(label);
- myCytoPanel.revalidate();
+ JPanel jpanel=new JPanel();
+ jpanel.setLayout(new GridLayout());
+ jpanel.add(label);
+ myCytoPanel.setJPanel(jpanel);
+
}
}
Modified:
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/MyCytoPanel.java
===================================================================
---
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/MyCytoPanel.java
2012-07-16 15:53:00 UTC (rev 29906)
+++
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/MyCytoPanel.java
2012-07-16 16:37:40 UTC (rev 29907)
@@ -1,136 +1,35 @@
package org.cytoscape.neildhruva.chartapp;
import java.awt.Component;
-import java.awt.Dimension;
import java.awt.GridLayout;
-import javax.swing.GroupLayout;
-import javax.swing.GroupLayout.SequentialGroup;
import javax.swing.Icon;
-import javax.swing.JCheckBox;
-import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import javax.swing.LayoutStyle;
import org.cytoscape.application.swing.CytoPanelComponent;
import org.cytoscape.application.swing.CytoPanelName;
-import org.jfree.chart.ChartPanel;
-import org.jfree.chart.JFreeChart;
+@SuppressWarnings("serial")
public class MyCytoPanel extends JPanel implements CytoPanelComponent {
- private static final long serialVersionUID = 8292806967891823933L;
-
- private JScrollPane jScrollPane1;
- private JCheckBox[] checkBoxArray;
- private GroupLayout layout;
- private int tableColumnCount;
- private ChartPanel myChart;
- private CytoChart cytoChart;
- private JComboBox jComboBox1;
- private JFreeChart chart;
-
public MyCytoPanel() {
JLabel label = new JLabel("Please select/import a network");
- this.setLayout(new GridLayout());
+ this.setLayout(new GridLayout());
this.add(label);
this.setVisible(true);
-
}
-
- /**
- * Initializes the <code>JTable</code> and the <code>JCheckBox</code>[]
array to be added to this <code>JPanel</code>
- *
- * @param jtable The <code>JTable</code> to be displayed in this
<code>JPanel</code>
- * @param checkBoxArray The <code>JCheckBox</code>[] array to be
displayed in this <code>JPanel</code>
- * @param tableColumnCount The initial column count of the
<code>JTable</code>
- */
- public void initComponents(JTable table, JCheckBox[] checkBoxArray, int
tableColumnCount, JComboBox jComboBox1){
-
- if(this.getComponents().length>0)
- this.removeAll();
-
- this.setBounds(0, 0, 2000, 2000);
- this.setPreferredSize(new Dimension(2000, 2000));
-
- this.checkBoxArray = checkBoxArray;
- this.tableColumnCount = tableColumnCount;
-
- table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
-
- cytoChart = new CytoChart(table);
- chart =
cytoChart.createChart(jComboBox1.getSelectedItem().toString());
- myChart = new ChartPanel(chart);
- myChart.setMouseWheelEnabled(true);
-
- jScrollPane1 = new JScrollPane();
- jScrollPane1.setViewportView(table);
-
jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
- jScrollPane1.setHorizontalScrollBarPolicy(JScrollPane
.HORIZONTAL_SCROLLBAR_AS_NEEDED);
-
- this.jComboBox1 = jComboBox1;
-
- layout = new GroupLayout(this);
- this.setLayout(layout);
-
- initPanel();
- this.revalidate();
-
- }
-
- /**
- * Adds the <code>JTable</code> and the <code>JCheckBox</code>[] array
to the layout of
- * this <code>JPanel</code>.
- *
- */
- public void initPanel(){
-
- GroupLayout.ParallelGroup checkBoxGroupHor =
layout.createParallelGroup(GroupLayout.Alignment.LEADING);
- for(int i=0;i<tableColumnCount;i++) {
- checkBoxGroupHor.addComponent(checkBoxArray[i]);
- }
- checkBoxGroupHor.addComponent(jComboBox1);
-
- layout.setHorizontalGroup(
-
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(6, 6, 6)
-
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(checkBoxGroupHor)
- .addGap(81, 81, 81)
- .addComponent(myChart, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addComponent(jComboBox1,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(98, 98, 98))
- );
-
- SequentialGroup checkBoxGroupVert = layout.createSequentialGroup();
- checkBoxGroupVert.addContainerGap();
- for(int i=0;i<tableColumnCount;i++){
- checkBoxGroupVert.addComponent(checkBoxArray[i]);
- if(i!=(tableColumnCount-1)) {
-
checkBoxGroupVert.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED);
- }
- }
-
- layout.setVerticalGroup(
-
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
-
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(myChart, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
- .addGroup(checkBoxGroupVert
- .addGap(18, 18, 18)
- .addComponent(jComboBox1,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
- .addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
- );
-
- }
-
+
+ /**
+ * Resets the JPanel contained in this CytoPanel.
+ * @param jpanel The new JPanel that contains the chart, checkboxes etc.
+ */
+ public void setJPanel(JPanel jpanel) {
+ this.removeAll();
+ this.add(jpanel);
+ this.revalidate();
+ }
+
public Component getComponent() {
return this;
}
@@ -156,19 +55,4 @@
return null;
}
- /**
- * @return Instance of {@link CytoChart} used to get access to the
current chart or create a new chart.
- */
- public CytoChart getCytoChart() {
- return this.cytoChart;
- }
-
- /**
- * Sets the new chart within the {@link ChartPanel}.
- *
- */
- public void setChartPanel(String chartType) {
- chart = cytoChart.createChart(chartType);
- myChart.setChart(chart);
- }
}
Modified:
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/PanelComponents.java
===================================================================
---
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/PanelComponents.java
2012-07-16 15:53:00 UTC (rev 29906)
+++
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/PanelComponents.java
2012-07-16 16:37:40 UTC (rev 29907)
@@ -25,8 +25,7 @@
private List<Boolean> checkBoxState;
private List<String> columnNamesList;
private JComboBox chartTypeComboBox;
- private MyCytoPanel myCytoPanel;
- private String chartType;
+ private PanelLayout panelLayout;
public enum chartTypes {
BAR {
@@ -35,25 +34,26 @@
}
},
- Line {
+ LINE {
public String toString() {
return "Line Chart";
}
}
}
- public PanelComponents(MyCytoPanel myCytoPanel) {
- this.myCytoPanel = myCytoPanel;
+ public PanelComponents(PanelLayout panelLayout) {
+ this.panelLayout = panelLayout;
}
/**
- * Initializes an array of checkboxes with column names of the table as
titles and
+ * Initializes an array of checkboxes with column names of the table as
titles and
* sets each checkbox checked/unchecked corresponding to the Boolean
values in which track hidden columns.
- * The checkboxes allows user to check/uncheck a particular column.
- *
- */
+ * The checkboxes allows user to check/uncheck a particular column.
+ * @param myCyTable The custom CyTable that stores information about
hidden columns, type of chart and column names.
+ * @param cytable The CyTable supplied by the user.
+ */
@SuppressWarnings("unchecked")
- public void initCheckBoxArray(CyTable myCyTable, CyTable cytable){
+ public void initComponents(CyTable myCyTable, CyTable cytable){
this.myCyTable = myCyTable;
this.table = new JTable(new MyTableModel(cytable));
@@ -109,7 +109,7 @@
chartTypeComboBox.addActionListener(new ActionListener () {
public void actionPerformed(ActionEvent e) {
String chartType = ((JComboBox)
e.getSource()).getSelectedItem().toString();
- myCytoPanel.setChartPanel(chartType);
+ panelLayout.setChartPanel(chartType);
updateChartType(chartType);
}
});
@@ -121,7 +121,6 @@
/**
* Hides the column from the table view by removing it from the table
column model.
- *
* @param columnName Name of the column that has to be hidden.
*/
public void hideColumn(String columnName) {
@@ -139,7 +138,6 @@
/**
* Makes a column visible in the JTable.
- *
* @param columnName Name of the column that has to be made visible.
*/
public void showColumn(String columnName) {
@@ -161,16 +159,14 @@
}
/**
- *
- * @param chartType
+ * Update the chart type in the custom CyTable attached to the network.
+ * @param chartType One of the types of charts listed in {@link
chartTypes}.
*/
public void updateChartType(String chartType) {
myCyTable.getAllRows().get(0).set("ChartType", chartType);
- this.chartType = chartType;
}
/**
- *
* @return The modified checkbox array after the user has
selected/deselected
* some checkboxes.
*/
@@ -179,7 +175,6 @@
}
/**
- *
* @return The modified checkbox array after the user has
selected/deselected
* some checkboxes.
*/
@@ -188,27 +183,10 @@
}
/**
- *
- * @return The initial column count of the table.
- */
- public int getTableColumnCount(){
- return this.columnCount;
- }
-
- /**
- *
* @return The modified JTable after some rows have been made invisible.
*/
public JTable getTable(){
return this.table;
}
- /**
- *
- * @return The Chart type string.
- */
- public String getChartType(){
- return this.chartType;
- }
-
}
Added:
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/PanelLayout.java
===================================================================
---
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/PanelLayout.java
(rev 0)
+++
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/PanelLayout.java
2012-07-16 16:37:40 UTC (rev 29907)
@@ -0,0 +1,137 @@
+package org.cytoscape.neildhruva.chartapp;
+
+import java.awt.Dimension;
+import java.util.ArrayList;
+
+import javax.swing.GroupLayout;
+import javax.swing.GroupLayout.SequentialGroup;
+import javax.swing.JComboBox;
+import javax.swing.JCheckBox;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.LayoutStyle;
+
+import org.cytoscape.model.CyIdentifiable;
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNetworkTableManager;
+import org.cytoscape.model.CyRow;
+import org.cytoscape.model.CyTable;
+import org.cytoscape.model.CyTableFactory;
+import org.cytoscape.model.CyTableManager;
+import org.jfree.chart.ChartPanel;
+import org.jfree.chart.JFreeChart;
+
+public class PanelLayout {
+
+ private JPanel jpanel;
+ private JScrollPane jScrollPane1;
+ private JCheckBox[] checkBoxArray;
+ private GroupLayout layout;
+ private int tableColumnCount;
+ private ChartPanel myChart;
+ private CytoChart cytoChart;
+ private JComboBox jComboBox1;
+ private JFreeChart chart;
+
+ public PanelLayout () {
+ this.jpanel = new JPanel();
+ }
+
+
+ /**
+ * Initializes the JTable and the JCheckBox[] array to be added to
jpanel.
+ * @param jtable The JTable to be displayed in jpanel.
+ * @param tableColumnCount The initial column count of the JTable .
+ * @param checkBoxArray The JCheckBox[] array to be displayed in
jpanel.
+ * @param jComboBox1 Used to select the type of chart.
+ */
+ public JPanel initLayout(JTable table, int tableColumnCount,
JCheckBox[] checkBoxArray, JComboBox jComboBox1){
+
+ if(jpanel.getComponents().length>0)
+ jpanel.removeAll();
+
+ jpanel.setBounds(0, 0, 2000, 2000);
+ jpanel.setPreferredSize(new Dimension(2000, 2000));
+
+ this.checkBoxArray = checkBoxArray;
+ this.tableColumnCount =tableColumnCount;
+
+ table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
+
+ cytoChart = new CytoChart(table);
+ chart =
cytoChart.createChart(jComboBox1.getSelectedItem().toString());
+ myChart = new ChartPanel(chart);
+ myChart.setMouseWheelEnabled(true);
+
+ jScrollPane1 = new JScrollPane();
+ jScrollPane1.setViewportView(table);
+
jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
+ jScrollPane1.setHorizontalScrollBarPolicy(JScrollPane
.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+
+ this.jComboBox1 = jComboBox1;
+
+ layout = new GroupLayout(jpanel);
+ jpanel.setLayout(layout);
+
+ initPanel();
+ return jpanel;
+
+ }
+
+ /**
+ * Adds the JTable and the JCheckBox[] array to the layout of jpanel.
+ */
+ public void initPanel(){
+
+ GroupLayout.ParallelGroup checkBoxGroupHor =
layout.createParallelGroup(GroupLayout.Alignment.LEADING);
+ for(int i=0;i<tableColumnCount;i++) {
+ checkBoxGroupHor.addComponent(checkBoxArray[i]);
+ }
+ checkBoxGroupHor.addComponent(jComboBox1);
+
+ layout.setHorizontalGroup(
+
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(6, 6, 6)
+
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(checkBoxGroupHor)
+ .addGap(81, 81, 81)
+ .addComponent(myChart, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+ .addComponent(jComboBox1,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGap(98, 98, 98))
+ );
+
+ SequentialGroup checkBoxGroupVert = layout.createSequentialGroup();
+ checkBoxGroupVert.addContainerGap();
+ for(int i=0;i<tableColumnCount;i++){
+ checkBoxGroupVert.addComponent(checkBoxArray[i]);
+ if(i!=(tableColumnCount-1)) {
+
checkBoxGroupVert.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED);
+ }
+ }
+
+ layout.setVerticalGroup(
+
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(myChart, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addGroup(checkBoxGroupVert
+ .addGap(18, 18, 18)
+ .addComponent(jComboBox1,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
+ );
+
+ }
+
+ /**
+ * Sets the new chart within the {@link ChartPanel}.
+ */
+ public void setChartPanel(String chartType) {
+ chart = cytoChart.createChart(chartType);
+ myChart.setChart(chart);
+ }
+}
Added:
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/impl/ChartAppFactory.java
===================================================================
---
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/impl/ChartAppFactory.java
(rev 0)
+++
csplugins/trunk/soc/neildhruva/ChartApp/src/main/java/org/cytoscape/neildhruva/chartapp/impl/ChartAppFactory.java
2012-07-16 16:37:40 UTC (rev 29907)
@@ -0,0 +1,18 @@
+package org.cytoscape.neildhruva.chartapp.impl;
+
+import javax.swing.JPanel;
+
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyTable;
+
+public interface ChartAppFactory {
+
+ /**
+ * Creates a {@link JPanel} consisting of a JFreeChart, checkboxes with
column names etc.
+ * @param currentNetwork The current {@link CyNetwork}.
+ * @param cyTable The {@link CyTable} that contains values to be
plotted on the {@link JFreeChart}
+ * @return The {@link JPanel} consisting of the chart, checkboxes with
column names etc.
+ */
+ JPanel createPanel(CyNetwork currentNetwork, CyTable cyTable);
+
+}
--
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.