本文整理汇总了Java中org.cytoscape.model.CyRow.set方法的典型用法代码示例。如果您正苦于以下问题:Java CyRow.set方法的具体用法?Java CyRow.set怎么用?Java CyRow.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.cytoscape.model.CyRow
的用法示例。
在下文中一共展示了CyRow.set方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serializeSession
import org.cytoscape.model.CyRow; //导入方法依赖的package包/类
void serializeSession(CyTable dataTable,
SafeSession session) {
CyNetworkView networkView = session.getNetworkView();
CyNetwork network = networkView.getModel();
CyTable networkTable = network.getDefaultNetworkTable();
CyRow row = networkTable.getRow(network.getSUID());
checkColumn(networkTable, DATA_TABLE_COLUMN, Long.class);
Long suid = dataTable.getSUID();
row.set(DATA_TABLE_COLUMN, suid);
CyRow viewRow = dataTable.getRow(networkView.getSUID());
try (StringWriter writer = new StringWriter()) {
toJson(session, writer);
String json = writer.toString();
viewRow.set(SAFE_DATA_COLUMN, json);
} catch (IOException e) {
e.printStackTrace();
}
}
示例2: set
import org.cytoscape.model.CyRow; //导入方法依赖的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);
}
}
示例3: selectEdges
import org.cytoscape.model.CyRow; //导入方法依赖的package包/类
public void selectEdges(String n1, String n2) {
CyTable nodeTable = network.getDefaultNodeTable();
List<CyEdge> edges = network.getEdgeList();
for(CyRow row : nodeTable.getAllRows()) {
row.set(CyNetwork.SELECTED, false);
}
for(CyEdge edge : edges) {
if((network.getRow(edge.getSource()).get(CyNetwork.NAME, String.class).equalsIgnoreCase(n1) && network.getRow(edge.getTarget()).get(CyNetwork.NAME, String.class).equalsIgnoreCase(n2)) ||
(network.getRow(edge.getSource()).get(CyNetwork.NAME, String.class).equalsIgnoreCase(n2) && network.getRow(edge.getTarget()).get(CyNetwork.NAME, String.class).equalsIgnoreCase(n1))) {
network.getRow(edge).set(CyNetwork.SELECTED, true);
}
else{
network.getRow(edge).set(CyNetwork.SELECTED, false);
}
}
if (networkView != null) {
networkView.updateView();
applicationManager.setCurrentNetworkView(networkView);
}
}
示例4: set
import org.cytoscape.model.CyRow; //导入方法依赖的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);
}
}
示例5: valueChanged
import org.cytoscape.model.CyRow; //导入方法依赖的package包/类
@Override
public void valueChanged(ListSelectionEvent e) {
if(e.getValueIsAdjusting())
return;
ClusterTableModel model = (ClusterTableModel)table.getModel();
AnnotationSet annotationSet = model.getAnnotationSet();
if(annotationSet == null)
return;
Set<CyNode> nodesToSelect =
Arrays.stream(table.getSelectedRows())
.map(table::convertRowIndexToModel)
.mapToObj(model::getCluster)
.flatMap(c -> c.getNodes().stream())
.collect(Collectors.toSet());
CyNetwork network = annotationSet.getParent().getNetwork();
for(CyNode node : network.getNodeList()) {
CyRow row = network.getRow(node);
// Test if the node is already in the correct state, don't fire unnecessary events
boolean select = nodesToSelect.contains(node);
if(!Boolean.valueOf(select).equals(row.get(CyNetwork.SELECTED, Boolean.class))) {
row.set(CyNetwork.SELECTED, select);
}
}
}
示例6: aggregateAttributes
import org.cytoscape.model.CyRow; //导入方法依赖的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);
}
}
}
示例7: createNode
import org.cytoscape.model.CyRow; //导入方法依赖的package包/类
public static CyNode createNode(CyNetwork network, String name, String cluster) {
CyNode node = network.addNode();
CyRow row = network.getRow(node);
row.set(CyNetwork.NAME, name);
row.set(CLUSTER_COL, cluster);
return node;
}
示例8: addCount
import org.cytoscape.model.CyRow; //导入方法依赖的package包/类
/**
* Add the specified count in the specified column name to the specified node.
*
* @param node node
* @param network network
* @param columnName column name
* @param count count
*/
static void addCount(final CyNode node, final CyNetwork network, final String columnName, final int count)
{
CyTable table = network.getDefaultNodeTable();
CyRow row = table.getRow(node.getSUID());
if (table.getColumn(columnName) == null)
{
table.createColumn(columnName, Integer.class, false);
}
// todo: or add to current value
row.set(columnName, count);
}
示例9: run
import org.cytoscape.model.CyRow; //导入方法依赖的package包/类
@Override
public void run(TaskMonitor tm) throws Exception {
CyNetwork network = targetNetwork.getSelectedValue();
CyTable targetTable = mappingManager.getMappingTable(network, targetClass.getSelectedValue().getTargetClass());
//Create the actual mapping
CyColumn mappingColumn = null;
if(createNewColumn)
{
targetTable.createColumn(newColumnName, DataSeriesMappingManager.MAPPING_COLUMN_CLASS, false);
mappingColumn = targetTable.getColumn(newColumnName);
}
else
{
mappingColumn = targetTable.getColumn(existingColumnForMapping.getSelectedValue());
}
if(mappingColumn == null)
{
throw new DataSeriesException("Could not get/create the column for mapping");
}
if(!mappingColumn.getType().equals(DataSeriesMappingManager.MAPPING_COLUMN_CLASS))
{
throw new DataSeriesException("The mapping column is of wrong type (should be " + DataSeriesMappingManager.MAPPING_COLUMN_CLASS.getSimpleName() + ", is" + mappingColumn.getType().getSimpleName() + ")");
}
mappingManager.mapDataSeriesRowsToTableColumn(targetNetwork.getSelectedValue(), targetClass.getSelectedValue().targetClass, mappingColumn.getName(), dataSeries.getSelectedValue());
//Fill the mapping column
if(mapByRowNames)
{
CyColumn rowNamesColumn = targetTable.getColumn(mapRowNamesWithColumn.getSelectedValue());
if(rowNamesColumn == null || !rowNamesColumn.getType().equals(String.class))
{
throw new DataSeriesException("The column for row names matches (" + mapRowNamesWithColumn.getSelectedValue() + ") has to exist and be of type string.");
}
int mapped = 0;
int notMapped = 0;
int empty = 0;
for(CyRow row : targetTable.getAllRows())
{
String rowNameInData = row.get(mapRowNamesWithColumn.getSelectedValue(), String.class);
if(rowNameInData == null || rowNameInData.isEmpty())
{
row.set(mappingColumn.getName(), null);
empty++;
}
else
{
List<String> rowNames = dataSeries.getSelectedValue().getRowNames();
int rowIndex = rowNames.indexOf(rowNameInData);
if(rowIndex < 0)
{
row.set(mappingColumn.getName(), null);
notMapped++;
}
else
{
int rowID = dataSeries.getSelectedValue().getRowID(rowIndex);
if (rowNames.lastIndexOf(rowNameInData) != rowIndex)
{
userLogger.warn("The data series '" + dataSeries.getSelectedValue().getName() + "' contains multiple rows with name '" + rowNameInData + "'. Mapping the node '" + rowNameInData + "' to row ID " + rowID);
}
row.set(mappingColumn.getName(), rowID);
mapped++;
}
}
}
userLogger.info("Mapped " + mapped + " rows to data series " + dataSeries.getSelectedValue().getName() + ", " + notMapped + " rows could not be mapped, " + empty + " rows were empty.");
}
}
示例10: exportModel
import org.cytoscape.model.CyRow; //导入方法依赖的package包/类
private void exportModel(NetworkViewSet nvs, CyTable asTable, CyTable clusterTable, Ids ids) {
AnnotationPersistor annotationPersistor = annotationPersistorProvider.get();
for(AnnotationSet as : nvs.getAnnotationSets()) {
CyRow asRow = asTable.getRow(ids.asId);
asRow.set(NAME, as.getName());
asRow.set(NETWORK_VIEW_SUID, as.getParent().getNetworkView().getSUID());
asRow.set(LABEL_COLUMN, Arrays.asList(as.getLabelColumn())); // may want to support multiple label columns in the future
asRow.set(ACTIVE, as.isActive());
DisplayOptions disp = as.getDisplayOptions();
asRow.set(SHAPE_TYPE, disp.getShapeType().name());
asRow.set(SHOW_CLUSTERS, disp.isShowClusters());
asRow.set(SHOW_LABELS, disp.isShowLabels());
asRow.set(USE_CONSTANT_FONT_SIZE, disp.isUseConstantFontSize());
asRow.set(FONT_SCALE, disp.getFontScale());
asRow.set(FONT_SIZE, disp.getFontSize());
asRow.set(OPACITY, disp.getOpacity());
asRow.set(BORDER_WIDTH, disp.getBorderWidth());
asRow.set(FILL_COLOR, disp.getFillColor().getRGB());
asRow.set(BORDER_COLOR, disp.getBorderColor().getRGB());
asRow.set(FONT_COLOR, disp.getFontColor().getRGB());
LabelMakerManager labelMakerManager = labelManagerProvider.get();
LabelMakerFactory labelFactory = labelMakerManager.getFactory(as);
Object context = labelMakerManager.getContext(as, labelFactory);
if(labelFactory != null && context != null) {
String serializedContext = labelFactory.serializeContext(context);
asRow.set(LABEL_MAKER_ID, labelFactory.getID());
asRow.set(LABEL_MAKER_CONTEXT, serializedContext);
}
Gson gson = new Gson();
String cpJson = gson.toJson(as.getCreationParameters());
asRow.set(CREATION_PARAMS, cpJson);
for(Cluster cluster : as.getClusters()) {
CyRow clusterRow = clusterTable.getRow(ids.clusterId);
clusterRow.set(LABEL, cluster.getLabel());
clusterRow.set(COLLAPSED, cluster.isCollapsed());
clusterRow.set(NODES_SUID, cluster.getNodes().stream().map(CyNode::getSUID).collect(Collectors.toList()));
clusterRow.set(ANNOTATION_SET_ID, ids.asId);
Optional<UUID> shapeID = annotationPersistor.getShapeID(cluster);
clusterRow.set(SHAPE_ID, shapeID.map(UUID::toString).orElse(null));
Optional<UUID> textID = annotationPersistor.getTextID(cluster);
clusterRow.set(TEXT_ID, textID.map(UUID::toString).orElse(null));
ids.clusterId++;
}
ids.asId++;
}
}
示例11: cloneRow
import org.cytoscape.model.CyRow; //导入方法依赖的package包/类
private void cloneRow(final CyRow from, final CyRow to) {
for (final CyColumn column : from.getTable().getColumns()){
if (!column.getVirtualColumnInfo().isVirtual())
to.set(column.getName(), from.getRaw(column.getName()));
}
}