Skip to content

Commit 2d5e813

Browse files
committed
Resolving conflict among the betweenness column created by Gephi versus the column with the same name created by this plugin; plotting in the VERTICAL orientation; dividing the domain into ten tips according to the maximum value
1 parent 3340a99 commit 2d5e813

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetric.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
import org.jfree.data.xy.XYSeriesCollection;
3131
import org.openide.util.NbBundle;
3232
import java.math.BigDecimal;
33+
import org.jfree.chart.plot.XYPlot;
34+
import org.jfree.chart.axis.NumberAxis;
35+
import org.jfree.chart.axis.NumberTickUnit;
3336

3437
/**
3538
*
@@ -39,6 +42,7 @@ public class BridgingCentralityMetric extends GraphDistance implements Statistic
3942

4043
private static final Logger logger = Logger.getLogger(BridgingCentralityMetric.class.getName());
4144

45+
public static final String BETWEENNESS_CENTRALITY = "betweennesscentrality2";
4246
public static final String BRIDGING_CENTRALITY = "bridgingcentrality";
4347
public static final String BRIDGING_COEFFICIENT = "bridgingcoefficient";
4448

@@ -147,8 +151,8 @@ private void initializeAttributeColunms(GraphModel graphModel) {
147151

148152
Table nodeTable = graphModel.getNodeTable();
149153

150-
if ( ! nodeTable.hasColumn(BETWEENNESS) ){
151-
nodeTable.addColumn(BETWEENNESS, "Betweenness Centrality", BigDecimal.class, new BigDecimal("0"));
154+
if ( ! nodeTable.hasColumn(BETWEENNESS_CENTRALITY) ){
155+
nodeTable.addColumn(BETWEENNESS_CENTRALITY, "Betweenness Centrality", BigDecimal.class, new BigDecimal("0"));
152156
}
153157

154158
if ( ! nodeTable.hasColumn(BRIDGING_COEFFICIENT) ){
@@ -314,7 +318,7 @@ private void saveCalculatedValues(Graph graph, HashMap<Node, Integer> indicies,
314318
//The bridging centrality is just a multiplication of two other metrics
315319
bridging_cent[s_index] = bridging_coef * mybetweenness[s_index];
316320

317-
s.setAttribute(BETWEENNESS, new BigDecimal (nodeBetweenness[s_index]));
321+
s.setAttribute(BETWEENNESS_CENTRALITY, new BigDecimal (nodeBetweenness[s_index]));
318322
s.setAttribute(BRIDGING_COEFFICIENT, new BigDecimal (bridging_coef));
319323
s.setAttribute(BRIDGING_CENTRALITY, new BigDecimal (bridging_cent[s_index]));
320324
}
@@ -471,20 +475,26 @@ private String createImageFile(TempDir tempDir, double[] pVals, String pName, St
471475

472476
XYSeriesCollection dataset = new XYSeriesCollection();
473477
dataset.addSeries(dSeries);
478+
dataset.setAutoWidth(true);
474479

475480
JFreeChart chart = ChartFactory.createXYLineChart(
476481
pName,
477482
pX,
478483
pY,
479484
dataset,
480-
PlotOrientation.HORIZONTAL,
485+
PlotOrientation.VERTICAL,
481486
true,
482487
false,
483488
false);
484489

490+
XYPlot xyPlot = (XYPlot) chart.getPlot();
491+
NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis();
492+
domain.setRange(0.00, domain.getUpperBound());
493+
domain.setTickUnit(new NumberTickUnit(domain.getUpperBound()/10));
494+
485495
chart.removeLegend();
486496
ChartUtils.decorateChart(chart);
487-
ChartUtils.scaleChart(chart, dSeries, normalized);
497+
// ChartUtils.scaleChart(chart, dSeries, normalized);
488498

489499
return ChartUtils.renderChart(chart, pName + ".png");
490500
}

0 commit comments

Comments
 (0)