@Test public void testSetWeight() { CyEdge edge = mock(CyEdge.class); CyRow row = mock(CyRow.class); LayoutEdge layoutEdge = new LayoutEdge(edge, row); ew.setWeight(layoutEdge); }
public void setWeight(LayoutEdge layoutEdge) { CyRow row = layoutEdge.getRow(); double eValue = defaultEdgeWeight; if (weightAttribute != null && row.isSet(weightAttribute)) { final Class<?> type = row.getTable().getColumn(weightAttribute).getType(); if (type == Integer.class) { Integer val = row.get(weightAttribute, Integer.class); eValue = (double) val.intValue(); } else if (type == Long.class) { Long val = row.get(weightAttribute, Long.class); eValue = (double) val.longValue(); } else if (type == Double.class) { Double val = row.get(weightAttribute, Double.class); if (!val.isNaN()) eValue = val.doubleValue(); } } layoutEdge.setWeight(eValue); minWeight = Math.min(minWeight,eValue); maxWeight = Math.max(maxWeight,eValue); if (type == WeightTypes.GUESS || type == WeightTypes.LOG) { double logWeight; if (eValue == 0) { logWeight = logWeightCeiling; logOverflow = true; } else { logWeight = Math.min(-Math.log10(eValue), logWeightCeiling); } minLogWeight = Math.min(minLogWeight,logWeight); maxLogWeight = Math.max(maxLogWeight,logWeight); layoutEdge.setLogWeight(logWeight); } }
EdgeWeighter { public void setWeight(LayoutEdge layoutEdge) { CyRow row = layoutEdge.getRow(); double eValue = defaultEdgeWeight; if (weightAttribute != null && row.isSet(weightAttribute)) { final Class<?> type = row.getTable().getColumn(weightAttribute).getType(); if (type == Integer.class) { Integer val = row.get(weightAttribute, Integer.class); eValue = (double) val.intValue(); } else if (type == Long.class) { Long val = row.get(weightAttribute, Long.class); eValue = (double) val.longValue(); } else if (type == Double.class) { Double val = row.get(weightAttribute, Double.class); if (!val.isNaN()) eValue = val.doubleValue(); } } layoutEdge.setWeight(eValue); minWeight = Math.min(minWeight,eValue); maxWeight = Math.max(maxWeight,eValue); if (type == WeightTypes.GUESS || type == WeightTypes.LOG) { double logWeight; if (eValue == 0) { logWeight = logWeightCeiling; logOverflow = true; } else { logWeight = Math.min(-Math.log10(eValue), logWeightCeiling); } minLogWeight = Math.min(minLogWeight,logWeight); maxLogWeight = Math.max(maxLogWeight,logWeight); layoutEdge.setLogWeight(logWeight); } } }
EdgeWeighter { public void setWeight(LayoutEdge layoutEdge) { CyRow row = layoutEdge.getRow(); double eValue = defaultEdgeWeight; if (weightAttribute != null && row.isSet(weightAttribute)) { final Class<?> type = row.getTable().getColumn(weightAttribute).getType(); if (type == Integer.class) { Integer val = row.get(weightAttribute, Integer.class); eValue = (double) val.intValue(); } else if (type == Long.class) { Long val = row.get(weightAttribute, Long.class); eValue = (double) val.longValue(); } else if (type == Double.class) { Double val = row.get(weightAttribute, Double.class); if (!val.isNaN()) eValue = val.doubleValue(); } } layoutEdge.setWeight(eValue); minWeight = Math.min(minWeight,eValue); maxWeight = Math.max(maxWeight,eValue); if (type == WeightTypes.GUESS || type == WeightTypes.LOG) { double logWeight; if (eValue == 0) { logWeight = logWeightCeiling; logOverflow = true; } else { logWeight = Math.min(-Math.log10(eValue), logWeightCeiling); } minLogWeight = Math.min(minLogWeight,logWeight); maxLogWeight = Math.max(maxLogWeight,logWeight); layoutEdge.setLogWeight(logWeight); } }  }
EdgeWeighter { public void setWeight(LayoutEdge layoutEdge) { CyRow row = layoutEdge.getRow(); double eValue = defaultEdgeWeight; if (weightAttribute != null && row.isSet(weightAttribute)) { final Class<?> type = row.getTable().getColumn(weightAttribute).getType(); if (type == Integer.class) { Integer val = row.get(weightAttribute, Integer.class); eValue = (double) val.intValue(); } else if (type == Long.class) { Long val = row.get(weightAttribute, Long.class); eValue = (double) val.longValue(); } else if (type == Double.class) { Double val = row.get(weightAttribute, Double.class); if (!val.isNaN()) eValue = val.doubleValue(); } } layoutEdge.setWeight(eValue); minWeight = Math.min(minWeight,eValue); maxWeight = Math.max(maxWeight,eValue); if (type == WeightTypes.GUESS || type == WeightTypes.LOG) { double logWeight; if (eValue == 0) { logWeight = logWeightCeiling; logOverflow = true; } else { logWeight = Math.min(-Math.log10(eValue), logWeightCeiling); } minLogWeight = Math.min(minLogWeight,logWeight); maxLogWeight = Math.max(maxLogWeight,logWeight); layoutEdge.setLogWeight(logWeight); } }  @Tunable(description="How to interpret weight values:", groups={"Edge Weight Settings"}, gravity=2.0, context="both", longDescription="How to interpret weight values; must be one of ```Heuristic```, ```-Log(value)```, ```1 - normalized value``` and ```normalized value```. Defaults to ```Heuristic```", exampleStringValue="Heuristic") ListSingleSelection<WeightTypes> getType(); void setType(ListSingleSelection<WeightTypes> t); void setWeightAttribute(String weightAttribute); void reset(); void setWeightType(WeightTypes type); void setNormalizedBounds(double lowerBound, double upperBound); void setWeight(LayoutEdge layoutEdge); boolean normalizeWeight(LayoutEdge edge); void setMaxWeightCutoff(double maxWeight); void setMinWeightCutoff(double minWeight); }
EdgeWeighter { public void setWeight(LayoutEdge layoutEdge) { CyRow row = layoutEdge.getRow(); double eValue = defaultEdgeWeight; if (weightAttribute != null && row.isSet(weightAttribute)) { final Class<?> type = row.getTable().getColumn(weightAttribute).getType(); if (type == Integer.class) { Integer val = row.get(weightAttribute, Integer.class); eValue = (double) val.intValue(); } else if (type == Long.class) { Long val = row.get(weightAttribute, Long.class); eValue = (double) val.longValue(); } else if (type == Double.class) { Double val = row.get(weightAttribute, Double.class); if (!val.isNaN()) eValue = val.doubleValue(); } } layoutEdge.setWeight(eValue); minWeight = Math.min(minWeight,eValue); maxWeight = Math.max(maxWeight,eValue); if (type == WeightTypes.GUESS || type == WeightTypes.LOG) { double logWeight; if (eValue == 0) { logWeight = logWeightCeiling; logOverflow = true; } else { logWeight = Math.min(-Math.log10(eValue), logWeightCeiling); } minLogWeight = Math.min(minLogWeight,logWeight); maxLogWeight = Math.max(maxLogWeight,logWeight); layoutEdge.setLogWeight(logWeight); } }  @Tunable(description="How to interpret weight values:", groups={"Edge Weight Settings"}, gravity=2.0, context="both", longDescription="How to interpret weight values; must be one of ```Heuristic```, ```-Log(value)```, ```1 - normalized value``` and ```normalized value```. Defaults to ```Heuristic```", exampleStringValue="Heuristic") ListSingleSelection<WeightTypes> getType(); void setType(ListSingleSelection<WeightTypes> t); void setWeightAttribute(String weightAttribute); void reset(); void setWeightType(WeightTypes type); void setNormalizedBounds(double lowerBound, double upperBound); void setWeight(LayoutEdge layoutEdge); boolean normalizeWeight(LayoutEdge edge); void setMaxWeightCutoff(double maxWeight); void setMinWeightCutoff(double minWeight); public WeightTypes type; @Tunable(description="The minimum edge weight to consider:", groups={"Edge Weight Settings"}, context="both", longDescription="The minimum edge weight to consider, numeric values, default is 0", exampleStringValue="0")
	public double minWeightCutoff; @Tunable(description="The maximum edge weight to consider:", groups={"Edge Weight Settings"}, context="both", longDescription="The maximum edge weight to consider, default to the Double.MAX value", exampleStringValue="1000")
	public double maxWeightCutoff; @Tunable(description="The default edge weight to consider:", groups={"Edge Weight Settings"}, context="both", longDescription="The default edge weight to consider, default is 0.5 ", exampleStringValue="0.5")
	public double defaultEdgeWeight; }