Craig Raw
4 years ago
19 changed files with 283 additions and 41 deletions
@ -1 +1 @@ |
|||
Subproject commit 4e7f0611c4bd15ae983bd06feeb80ad69eedb853 |
|||
Subproject commit 49a4b548b4b93aa9b765b0b6f9520d0314b1395f |
@ -0,0 +1,31 @@ |
|||
package com.sparrowwallet.sparrow.control; |
|||
|
|||
import com.sparrowwallet.drongo.BitcoinUnit; |
|||
import javafx.scene.chart.NumberAxis; |
|||
import javafx.util.StringConverter; |
|||
|
|||
import java.text.ParseException; |
|||
|
|||
final class CoinAxisFormatter extends StringConverter<Number> { |
|||
private final BitcoinUnit bitcoinUnit; |
|||
|
|||
public CoinAxisFormatter(NumberAxis axis, BitcoinUnit unit) { |
|||
this.bitcoinUnit = unit; |
|||
} |
|||
|
|||
@Override |
|||
public String toString(Number object) { |
|||
Double value = bitcoinUnit.getValue(object.longValue()); |
|||
return CoinTextFormatter.COIN_FORMAT.format(value); |
|||
} |
|||
|
|||
@Override |
|||
public Number fromString(String string) { |
|||
try { |
|||
Number number = CoinTextFormatter.COIN_FORMAT.parse(string); |
|||
return bitcoinUnit.getSatsValue(number.doubleValue()); |
|||
} catch (ParseException e) { |
|||
throw new RuntimeException(e); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,36 @@ |
|||
package com.sparrowwallet.sparrow.control; |
|||
|
|||
import com.sparrowwallet.drongo.BitcoinUnit; |
|||
import com.sparrowwallet.drongo.wallet.Wallet; |
|||
import com.sparrowwallet.sparrow.io.Config; |
|||
import com.sparrowwallet.sparrow.wallet.Entry; |
|||
import javafx.scene.control.TreeTableView; |
|||
|
|||
public class CoinTreeTable extends TreeTableView<Entry> { |
|||
private BitcoinUnit bitcoinUnit; |
|||
|
|||
public BitcoinUnit getBitcoinUnit() { |
|||
return bitcoinUnit; |
|||
} |
|||
|
|||
public void setBitcoinUnit(BitcoinUnit bitcoinUnit) { |
|||
this.bitcoinUnit = bitcoinUnit; |
|||
} |
|||
|
|||
public void setBitcoinUnit(Wallet wallet) { |
|||
setBitcoinUnit(wallet, Config.get().getBitcoinUnit()); |
|||
} |
|||
|
|||
public void setBitcoinUnit(Wallet wallet, BitcoinUnit unit) { |
|||
if(unit == null || unit.equals(BitcoinUnit.AUTO)) { |
|||
unit = wallet.getAutoUnit(); |
|||
} |
|||
|
|||
boolean changed = (bitcoinUnit != unit); |
|||
this.bitcoinUnit = unit; |
|||
|
|||
if(changed && !getChildren().isEmpty()) { |
|||
refresh(); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,15 @@ |
|||
package com.sparrowwallet.sparrow.event; |
|||
|
|||
import com.sparrowwallet.drongo.BitcoinUnit; |
|||
|
|||
public class BitcoinUnitChangedEvent { |
|||
private final BitcoinUnit bitcoinUnit; |
|||
|
|||
public BitcoinUnitChangedEvent(BitcoinUnit bitcoinUnit) { |
|||
this.bitcoinUnit = bitcoinUnit; |
|||
} |
|||
|
|||
public BitcoinUnit getBitcoinUnit() { |
|||
return bitcoinUnit; |
|||
} |
|||
} |
Loading…
Reference in new issue