public mxGeneratorRandomFunction(double minWeight, double maxWeight, int roundToDecimals) { setWeightRange(minWeight, maxWeight); setRoundToDecimals(roundToDecimals); };
public mxGeneratorRandomIntFunction(double minWeight, double maxWeight) { setWeightRange(minWeight, maxWeight); };
/** * @param graph * @param weighted if true, the edges will be weighted, otherwise all will have default value (1.0) * @param minWeight minimum edge weight if weighted * @param maxWeight maximum edge weight if weighted * @return a generator function */ public static mxGeneratorFunction getGeneratorFunction(mxGraph graph, boolean weighted, double minWeight, double maxWeight) { if (weighted) { return new mxGeneratorRandomFunction(minWeight, maxWeight, 2); } else { return null; } };
public double getCost(mxCellState state) { Double edgeWeight = null; edgeWeight = Math.random() * (maxWeight - minWeight) + minWeight; edgeWeight = (double) Math.round(edgeWeight * Math.pow(10, getRoundToDecimals())) / Math.pow(10, getRoundToDecimals()); return edgeWeight; };
/** * Creates a new edge value based on graph properties in mxAnalysisGraph. Used mostly when creating new edges during graph generation. * @param aGraph * @return */ public Double getNewEdgeValue(mxAnalysisGraph aGraph) { if (getGeneratorFunction() != null) { mxGraph graph = aGraph.getGraph(); return getGeneratorFunction().getCost(graph.getView().getState(graph.getDefaultParent())); } else { return null; } };
public mxGeneratorRandomFunction(double minWeight, double maxWeight, int roundToDecimals) { setWeightRange(minWeight, maxWeight); setRoundToDecimals(roundToDecimals); };
public mxGeneratorRandomIntFunction(double minWeight, double maxWeight) { setWeightRange(minWeight, maxWeight); };
/** * @param graph * @param weighted if true, the edges will be weighted, otherwise all will have default value (1.0) * @param minWeight minimum edge weight if weighted * @param maxWeight maximum edge weight if weighted * @return a generator function */ public static mxGeneratorFunction getGeneratorFunction(mxGraph graph, boolean weighted, double minWeight, double maxWeight) { if (weighted) { return new mxGeneratorRandomFunction(minWeight, maxWeight, 2); } else { return null; } };
public double getCost(mxCellState state) { Double edgeWeight = null; edgeWeight = Math.random() * (maxWeight - minWeight) + minWeight; edgeWeight = (double) Math.round(edgeWeight * Math.pow(10, getRoundToDecimals())) / Math.pow(10, getRoundToDecimals()); return edgeWeight; };
/** * Creates a new edge value based on graph properties in mxAnalysisGraph. Used mostly when creating new edges during graph generation. * @param aGraph * @return */ public Double getNewEdgeValue(mxAnalysisGraph aGraph) { if (getGeneratorFunction() != null) { mxGraph graph = aGraph.getGraph(); return getGeneratorFunction().getCost(graph.getView().getState(graph.getDefaultParent())); } else { return null; } };