本文整理汇总了Java中org.cytoscape.model.CyTable.createListColumn方法的典型用法代码示例。如果您正苦于以下问题:Java CyTable.createListColumn方法的具体用法?Java CyTable.createListColumn怎么用?Java CyTable.createListColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.cytoscape.model.CyTable
的用法示例。
在下文中一共展示了CyTable.createListColumn方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: set
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
public static void set(CyNetwork network, CyIdentifiable entry, String tableName, String name, Object value, Class<?> type) {
CyRow row = network.getRow(entry, tableName);
CyTable table = row.getTable();
CyColumn column = table.getColumn(name);
if (value != null) {
if (column == null) {
if (value instanceof List) {
table.createListColumn(name, type, false);
}
else if (value instanceof Collection) {
throw new IllegalArgumentException("Arrt. values collection is not a List: "
+ value.getClass().getSimpleName());
}
else {
table.createColumn(name, type, false);
}
}
row.set(name, value);
}
}
示例2: addProperties
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
public static void addProperties(Long suid, CyTable table,Map<String,Object> props){
for(Entry<String,Object> obj : props.entrySet()){
if(table.getColumn(obj.getKey()) == null){
if(obj.getValue().getClass() == ArrayList.class){
table.createListColumn(obj.getKey(), CyUtils.getArrayListType((ArrayList)obj.getValue()), false);
} else {
table.createColumn(obj.getKey(), obj.getValue().getClass(), false);
}
}
CyUtils.addValueToTable(suid,obj.getKey(),obj.getValue(),table);
}
}
示例3: set
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
public static void set(CyNetwork network, CyIdentifiable entry, String tableName, String name, Object value, Class<?> type) {
CyRow row = network.getRow(entry, tableName);
CyTable table = row.getTable();
CyColumn column = table.getColumn(name);
if (value != null) {
if (column == null) {
if (value instanceof List) {
table.createListColumn(name, type, false);
}
else if (value instanceof Collection) {
throw new IllegalArgumentException("Attribute value is a Collection and not List: "
+ value.getClass().getSimpleName());
}
else {
table.createColumn(name, type, false);
}
}
row.set(name, value);
}
}
示例4: aggregateAttributes
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
private void aggregateAttributes(CyNetwork originNetwork, SummaryNetwork summaryNetwork) {
CyTable originNodeTable = originNetwork.getDefaultNodeTable();
CyTable summaryNodeTable = summaryNetwork.network.getDefaultNodeTable();
summaryNodeTable.createColumn("cluster node count", Integer.class, false);
List<String> columnsToAggregate = new ArrayList<>();
for(CyColumn column : originNodeTable.getColumns()) {
String name = column.getName();
if(summaryNodeTable.getColumn(name) == null) {
columnsToAggregate.add(name);
Class<?> listElementType = column.getListElementType();
if(listElementType == null) {
summaryNodeTable.createColumn(name, column.getType(), false);
}
else {
summaryNodeTable.createListColumn(name, listElementType, false);
}
}
}
for(SummaryCluster cluster : summaryNetwork.getClusters()) {
CyNode summaryNode = summaryNetwork.getNodeFor(cluster);
CyRow row = summaryNodeTable.getRow(summaryNode.getSUID());
row.set("name", cluster.getLabel());
row.set("cluster node count", cluster.getNodes().size());
for(String columnName : columnsToAggregate) {
Object result = aggregate(originNetwork, cluster, columnName);
row.set(columnName, result);
}
}
}
示例5: getOrCreateListColumn
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
public static CyColumn getOrCreateListColumn(String name, Class<?> type, boolean immutable, CyTable table) {
if (name == null) throw new NullPointerException("name cannot be null");
if (type == null) throw new NullPointerException("type cannot be null");
if (table == null) throw new NullPointerException("table cannot be null");
CyColumn column = table.getColumn(name);
if (column == null) {
table.createListColumn(name, type, immutable);
column = table.getColumn(name);
}
return column;
}
示例6: detectImmutableProblem
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
private static String detectImmutableProblem(String key, CyTable table, Class<?> valueClass, Class<?> colClass){
CyColumn col = table.getColumn(key);
String newKey = key; // trying to make this less confusing with the extra variables
if(col.isImmutable() && !matchingValues(valueClass,colClass)){
newKey = key + "_cannot_change_original";
// we had this problem before and fixed it, now use the fixed column instead of the previous one!
if(table.getColumn(newKey) == null){
if(table.getColumn(key).getListElementType() != null){
table.createListColumn(newKey,table.getColumn(key).getListElementType() , false);
} else {
table.createColumn(newKey, table.getColumn(key).getType(), false);
}
// populate the new column!
List<CyRow> rows = table.getAllRows();
for(CyRow row : rows){
if(row.isSet(key)){
table.getRow(row.get("SUID", Long.class)).set(newKey, row.getRaw(key));
}
}
}
}
return newKey;
}
示例7: addEdgeAttributes
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
private void addEdgeAttributes(final CyEdge element, final String column, final String entry)
{
final CyTable table = network.getRow(element).getTable();
if (table.getColumn(column) == null)
table.createListColumn(column, String.class, false);
List<String> value = Arrays.asList(entry.split(";"));
network.getRow(element).set(column, value);
}
示例8: createListColumn
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
private static void createListColumn(CyTable table, String name, Class<?> type) {
if(table.getColumn(name) == null)
table.createListColumn(name, type, true);
}
示例9: copyColumn
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
private void copyColumn(CyColumn col, CyTable subTable) {
if (List.class.isAssignableFrom(col.getType()))
subTable.createListColumn(col.getName(), col.getListElementType(), false);
else
subTable.createColumn(col.getName(), col.getType(), false);
}
示例10: setNodeAttribute
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
@Override
protected void setNodeAttribute(CyNode node, String colName, Object value)
{
// Turn URIs into strings
if (value instanceof RdfNode) { value = value.toString(); }
// Turn Float into Double. Float not accepted by Cytoscape as column type.
if (value instanceof Float) { value = ((Number)value).doubleValue(); }
CyTable table = myNet.getDefaultNodeTable();
if ("label".equals(colName))
{
// legacy hack - where label is used in sparql, map to attribute "name"
table.getRow(node.getSUID()).set("name", "" + value);
}
else
{
// if the column doesn't yet exist, crate it first
if (table.getColumn(colName) == null)
{
if (colName.endsWith("_list"))
{
table.createListColumn(colName, String.class, true);
}
else
{
Class<?> valueClass = value.getClass();
//NB: Float not accepted by Cytoscape, must be Double.
if (valueClass == Double.class ||
valueClass == Integer.class ||
valueClass == Boolean.class ||
valueClass == Long.class ||
valueClass == String.class)
{
table.createColumn(colName, valueClass, true);
}
else
{
throw new IllegalStateException ("Unable to handle attribute values of class " + valueClass);
}
}
}
try
{
if (colName.endsWith("_list"))
{
List<String> data = table.getRow(node.getSUID()).getList(colName, String.class);
if (data == null)
{
data = new ArrayList<String>();
data.add(StringUtils.safeToString(value));
table.getRow(node.getSUID()).set(colName, data);
}
else
{
data.add(StringUtils.safeToString(value));
}
}
else
{
// TODO: check for type mismatches?
table.getRow(node.getSUID()).set(colName, value);
}
}
catch (IllegalStateException e)
{
// class cast problem...
// TODO...
e.printStackTrace();
}
}
}
示例11: addValueToTable
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
public static void addValueToTable(Long suid, String key, Object value, CyTable table) {
Class<?> valueClass = value.getClass();
String fixedKey = detectImmutableProblem(key, table, valueClass, table.getColumn(key).getType());
Class<?> colClass = table.getColumn(fixedKey).getType();
Class<?> colTypeClass = table.getColumn(fixedKey).getListElementType();
if(valueClass.equals(colClass)){
table.getRow(suid).set(fixedKey, value);
return;
}
if(colClass.equals(Long.class) && valueClass.equals(Integer.class)){
table.getRow(suid).set(fixedKey, Long.valueOf(((Integer)value).longValue()));
return;
}
// both lists!
if(valueClass.equals(ArrayList.class) && colClass.equals(List.class)){
if(colTypeClass.equals(getArrayListType(value))){
table.getRow(suid).set(fixedKey, value);
} else {
System.out.println("same property but different value types in the arrays!!");
// why is here no else? because I don't want to start casting around! Neo4j allows properties to be different between nodes
// Cytoscape does not.
}
} else { // one is not a list!!
if(valueClass.equals(ArrayList.class)){ // need to change the colClass
// use the data from the original column!
Map<Long,Object> currData = new HashMap<Long,Object>();
List<CyRow> rows = table.getAllRows();
for(CyRow row : rows){
if(row.isSet(fixedKey)){
currData.put(row.get("SUID", Long.class),row.getRaw(fixedKey));
}
}
//
table.deleteColumn(fixedKey);
table.createListColumn(fixedKey, getArrayListType(value), false);
for(Entry<Long,Object> e : currData.entrySet()){
ArrayList fixedOldValue = new ArrayList();
fixedOldValue.add(e.getValue());
table.getRow(e.getKey()).set(fixedKey, fixedOldValue);
}
}
if(colClass.equals(List.class)){
ArrayList newValue = new ArrayList();
newValue.add(value);
table.getRow(suid).set(fixedKey, newValue);
}
}
}