Craig Raw
5 years ago
18 changed files with 392 additions and 75 deletions
@ -1 +1 @@ |
|||
Subproject commit 7fb5601de38e79d5c0547ebc684ca137aa895134 |
|||
Subproject commit a1696ec2e8d5ca17fc98246e374e9d3ae9ab368f |
@ -0,0 +1,46 @@ |
|||
package com.craigraw.sparrow.form; |
|||
|
|||
import com.craigraw.drongo.address.Address; |
|||
import com.craigraw.drongo.protocol.TransactionOutput; |
|||
import com.craigraw.drongo.protocol.NonStandardScriptException; |
|||
import javafx.collections.FXCollections; |
|||
import javafx.collections.ObservableList; |
|||
import javafx.scene.chart.PieChart; |
|||
import javafx.scene.control.Tooltip; |
|||
|
|||
import java.util.List; |
|||
|
|||
public abstract class FormController { |
|||
protected void addPieData(PieChart pie, List<TransactionOutput> outputs) { |
|||
ObservableList<PieChart.Data> outputsPieData = FXCollections.observableArrayList(); |
|||
|
|||
long totalAmt = 0; |
|||
for(TransactionOutput output : outputs) { |
|||
String name = "Unknown"; |
|||
try { |
|||
Address[] addresses = output.getScript().getToAddresses(); |
|||
if(addresses.length == 1) { |
|||
name = addresses[0].getAddress(); |
|||
} else { |
|||
name = "[" + addresses[0].getAddress() + ",...]"; |
|||
} |
|||
} catch(NonStandardScriptException e) { |
|||
//ignore
|
|||
} |
|||
|
|||
totalAmt += output.getValue(); |
|||
outputsPieData.add(new PieChart.Data(name, output.getValue())); |
|||
} |
|||
|
|||
pie.setData(outputsPieData); |
|||
|
|||
final double totalSum = totalAmt; |
|||
pie.getData().forEach(data -> { |
|||
Tooltip tooltip = new Tooltip(); |
|||
double percent = 100.0 * (data.getPieValue() / totalSum); |
|||
tooltip.setText(String.format("%.1f", percent) + "%"); |
|||
Tooltip.install(data.getNode(), tooltip); |
|||
data.pieValueProperty().addListener((observable, oldValue, newValue) -> tooltip.setText(newValue + "%")); |
|||
}); |
|||
} |
|||
} |
@ -0,0 +1,18 @@ |
|||
.version-color { -fx-fill: #986801 } |
|||
.segwit-marker-color { -fx-fill: #000000 } |
|||
.segwit-flag-color { -fx-fill: #4078f2 } |
|||
|
|||
.num-inputs-color { -fx-fill: #ca1243 } |
|||
.input-hash-color { -fx-fill: #0184bc } |
|||
.input-index-color { -fx-fill: #0184bc } |
|||
.input-sigscript-length-color { -fx-fill: #0184bc } |
|||
.input-sigscript-color { -fx-fill: #0184bc } |
|||
.input-sequence-color { -fx-fill: #0184bc } |
|||
|
|||
.num-outputs-color { -fx-fill: #ca1243 } |
|||
.output-value-color { -fx-fill: #50a14f } |
|||
.output-pubkeyscript-length-color { -fx-fill: #50a14f } |
|||
.output-pubkeyscript-color { -fx-fill: #50a14f } |
|||
|
|||
.witnesses-color { -fx-fill: #a626a4 } |
|||
.locktime-color { -fx-fill: #986801 } |
@ -0,0 +1,31 @@ |
|||
.version-color { -fx-fill: #e5e5e6 } |
|||
.segwit-marker-color { -fx-fill: #e5e5e6 } |
|||
.segwit-flag-color { -fx-fill: #e5e5e6 } |
|||
|
|||
.num-inputs-color { -fx-fill: #ca1243 } |
|||
.input-hash-color { -fx-fill: #0184bc } |
|||
.input-index-color { -fx-fill: #000000 } |
|||
.input-sigscript-length-color { -fx-fill: #a626a4 } |
|||
.input-sigscript-color { -fx-fill: #50a14f } |
|||
.input-sequence-color { -fx-fill: #986801 } |
|||
|
|||
.num-outputs-color { -fx-fill: #e5e5e6 } |
|||
.output-value-color { -fx-fill: #e5e5e6 } |
|||
.output-pubkeyscript-length-color { -fx-fill: #e5e5e6 } |
|||
.output-pubkeyscript-color { -fx-fill: #e5e5e6 } |
|||
|
|||
.witnesses-color { -fx-fill: #e5e5e6 } |
|||
.locktime-color { -fx-fill: #e5e5e6 } |
|||
|
|||
.chart-legend-item{ |
|||
-fx-font-family: Courier; |
|||
} |
|||
|
|||
.default-color0.chart-pie { -fx-pie-color: #ca1243 } |
|||
.default-color1.chart-pie { -fx-pie-color: #d75f00 } |
|||
.default-color2.chart-pie { -fx-pie-color: #0184bc } |
|||
.default-color3.chart-pie { -fx-pie-color: #c18401 } |
|||
.default-color4.chart-pie { -fx-pie-color: #50a14f } |
|||
.default-color5.chart-pie { -fx-pie-color: #4078f2 } |
|||
.default-color6.chart-pie { -fx-pie-color: #a626a4 } |
|||
.default-color7.chart-pie { -fx-pie-color: #986801 } |
@ -1,14 +1,45 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
|
|||
<?import java.lang.*?> |
|||
<?import java.util.*?> |
|||
<?import javafx.scene.*?> |
|||
<?import javafx.geometry.*?> |
|||
<?import javafx.scene.control.*?> |
|||
<?import javafx.scene.layout.*?> |
|||
<?import tornadofx.control.*?> |
|||
|
|||
<AnchorPane xmlns="http://javafx.com/javafx" |
|||
xmlns:fx="http://javafx.com/fxml" |
|||
fx:controller="com.craigraw.sparrow.form.InputsController" |
|||
prefHeight="400.0" prefWidth="600.0"> |
|||
<?import javafx.scene.chart.PieChart?> |
|||
<GridPane alignment="TOP_CENTER" hgap="10.0" prefHeight="500.0" prefWidth="600.0" stylesheets="@inputs.css, @../general.css" vgap="10.0" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.craigraw.sparrow.form.InputsController"> |
|||
<padding> |
|||
<Insets bottom="25.0" left="25.0" right="25.0" top="25.0" /> |
|||
</padding> |
|||
<columnConstraints> |
|||
<ColumnConstraints maxWidth="Infinity" minWidth="290" prefWidth="290"> |
|||
</ColumnConstraints> |
|||
<ColumnConstraints maxWidth="Infinity" minWidth="290" prefWidth="290"> |
|||
</ColumnConstraints> |
|||
</columnConstraints> |
|||
<rowConstraints> |
|||
<RowConstraints /> |
|||
</rowConstraints> |
|||
<Form GridPane.columnIndex="0" GridPane.rowIndex="0"> |
|||
<Fieldset inputGrow="SOMETIMES" text="Inputs"> |
|||
<Field text="Count:"> |
|||
<TextField fx:id="count" editable="false" minWidth="520" prefWidth="520" styleClass="copyable-label" /> |
|||
</Field> |
|||
<Field text="Total:"> |
|||
<TextField fx:id="total" editable="false" minWidth="520" prefWidth="520" styleClass="copyable-label" /> |
|||
</Field> |
|||
</Fieldset> |
|||
</Form> |
|||
|
|||
</AnchorPane> |
|||
<Form GridPane.columnIndex="1" GridPane.rowIndex="0"> |
|||
<Fieldset inputGrow="SOMETIMES" text="Signatures"> |
|||
<Field text="Status:"> |
|||
<TextField fx:id="signatures" editable="false" minWidth="520" prefWidth="520" styleClass="copyable-label" /> |
|||
</Field> |
|||
</Fieldset> |
|||
</Form> |
|||
|
|||
<Separator GridPane.columnIndex="0" GridPane.rowIndex="1" GridPane.columnSpan="2" styleClass="form-separator"/> |
|||
|
|||
<PieChart fx:id="inputsPie" prefHeight="400" GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.rowIndex="2" startAngle="180" labelLineLength="50" labelsVisible="false" /> |
|||
|
|||
</GridPane> |
|||
|
@ -0,0 +1,31 @@ |
|||
.version-color { -fx-fill: #e5e5e6 } |
|||
.segwit-marker-color { -fx-fill: #e5e5e6 } |
|||
.segwit-flag-color { -fx-fill: #e5e5e6 } |
|||
|
|||
.num-inputs-color { -fx-fill: #e5e5e6 } |
|||
.input-hash-color { -fx-fill: #e5e5e6 } |
|||
.input-index-color { -fx-fill: #e5e5e6 } |
|||
.input-sigscript-length-color { -fx-fill: #e5e5e6 } |
|||
.input-sigscript-color { -fx-fill: #e5e5e6 } |
|||
.input-sequence-color { -fx-fill: #e5e5e6 } |
|||
|
|||
.num-outputs-color { -fx-fill: #ca1243 } |
|||
.output-value-color { -fx-fill: #000000 } |
|||
.output-pubkeyscript-length-color { -fx-fill: #a626a4 } |
|||
.output-pubkeyscript-color { -fx-fill: #50a14f } |
|||
|
|||
.witnesses-color { -fx-fill: #e5e5e6 } |
|||
.locktime-color { -fx-fill: #e5e5e6 } |
|||
|
|||
.chart-legend-item{ |
|||
-fx-font-family: Courier; |
|||
} |
|||
|
|||
.default-color7.chart-pie { -fx-pie-color: #0184bc } |
|||
.default-color6.chart-pie { -fx-pie-color: #a626a4 } |
|||
.default-color5.chart-pie { -fx-pie-color: #d75f00 } |
|||
.default-color4.chart-pie { -fx-pie-color: #986801 } |
|||
.default-color3.chart-pie { -fx-pie-color: #ca1243 } |
|||
.default-color2.chart-pie { -fx-pie-color: #c18401 } |
|||
.default-color1.chart-pie { -fx-pie-color: #50a14f } |
|||
.default-color0.chart-pie { -fx-pie-color: #4078f2 } |
Loading…
Reference in new issue