Refactoring: Rename classes

This commit is contained in:
chimp1984 2021-02-05 22:08:19 -05:00
parent df6d451b80
commit 4244f807c7
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3
6 changed files with 47 additions and 47 deletions

View File

@ -73,7 +73,7 @@ import lombok.extern.slf4j.Slf4j;
import static bisq.desktop.util.FormBuilder.getTopLabelWithVBox; import static bisq.desktop.util.FormBuilder.getTopLabelWithVBox;
@Slf4j @Slf4j
public abstract class ChartView<T extends ChartModel> extends ActivatableView<VBox, T> { public abstract class ChartView<T extends ChartViewModel> extends ActivatableView<VBox, T> {
private final Pane center; private final Pane center;
private final SplitPane splitPane; private final SplitPane splitPane;
protected final NumberAxis xAxis; protected final NumberAxis xAxis;
@ -194,11 +194,11 @@ public abstract class ChartView<T extends ChartModel> extends ActivatableView<VB
dividerNodes.forEach(node -> node.setOnMouseReleased(null)); dividerNodes.forEach(node -> node.setOnMouseReleased(null));
} }
public void addListener(ChartModel.Listener listener) { public void addListener(ChartViewModel.Listener listener) {
model.addListener(listener); model.addListener(listener);
} }
public void removeListener(ChartModel.Listener listener) { public void removeListener(ChartViewModel.Listener listener) {
model.removeListener(listener); model.removeListener(listener);
} }

View File

@ -30,7 +30,7 @@ import java.util.function.Predicate;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
public abstract class ChartModel extends ActivatableViewModel { public abstract class ChartViewModel extends ActivatableViewModel {
public interface Listener { public interface Listener {
/** /**
* @param fromDate Epoch date in millis for earliest data * @param fromDate Epoch date in millis for earliest data
@ -44,7 +44,7 @@ public abstract class ChartModel extends ActivatableViewModel {
private Predicate<Long> predicate = e -> true; private Predicate<Long> predicate = e -> true;
public ChartModel() { public ChartViewModel() {
} }

View File

@ -20,9 +20,9 @@ package bisq.desktop.main.dao.economy.supply;
import bisq.desktop.common.view.ActivatableView; import bisq.desktop.common.view.ActivatableView;
import bisq.desktop.common.view.FxmlView; import bisq.desktop.common.view.FxmlView;
import bisq.desktop.components.TitledGroupBg; import bisq.desktop.components.TitledGroupBg;
import bisq.desktop.components.chart.ChartModel; import bisq.desktop.components.chart.ChartViewModel;
import bisq.desktop.main.dao.economy.supply.daodata.DaoDataChartView; import bisq.desktop.main.dao.economy.supply.daodata.DaoChartDataModel;
import bisq.desktop.main.dao.economy.supply.daodata.DaoDataModel; import bisq.desktop.main.dao.economy.supply.daodata.DaoChartView;
import bisq.desktop.util.Layout; import bisq.desktop.util.Layout;
import bisq.core.dao.DaoFacade; import bisq.core.dao.DaoFacade;
@ -49,11 +49,11 @@ import static bisq.desktop.util.FormBuilder.addTitledGroupBg;
import static bisq.desktop.util.FormBuilder.addTopLabelReadOnlyTextField; import static bisq.desktop.util.FormBuilder.addTopLabelReadOnlyTextField;
@FxmlView @FxmlView
public class SupplyView extends ActivatableView<GridPane, Void> implements DaoStateListener, ChartModel.Listener { public class SupplyView extends ActivatableView<GridPane, Void> implements DaoStateListener, ChartViewModel.Listener {
private final DaoFacade daoFacade; private final DaoFacade daoFacade;
private final DaoDataChartView daoDataChartView; private final DaoChartView daoChartView;
// Shared model between SupplyView and RevenueChartModel // Shared model between SupplyView and RevenueChartModel
private final DaoDataModel daoDataModel; private final DaoChartDataModel daoChartDataModel;
private final BsqFormatter bsqFormatter; private final BsqFormatter bsqFormatter;
private TextField genesisIssueAmountTextField, compRequestIssueAmountTextField, reimbursementAmountTextField, private TextField genesisIssueAmountTextField, compRequestIssueAmountTextField, reimbursementAmountTextField,
@ -69,12 +69,12 @@ public class SupplyView extends ActivatableView<GridPane, Void> implements DaoSt
@Inject @Inject
private SupplyView(DaoFacade daoFacade, private SupplyView(DaoFacade daoFacade,
DaoDataChartView daoDataChartView, DaoChartView daoChartView,
DaoDataModel daoDataModel, DaoChartDataModel daoChartDataModel,
BsqFormatter bsqFormatter) { BsqFormatter bsqFormatter) {
this.daoFacade = daoFacade; this.daoFacade = daoFacade;
this.daoDataChartView = daoDataChartView; this.daoChartView = daoChartView;
this.daoDataModel = daoDataModel; this.daoChartDataModel = daoChartDataModel;
this.bsqFormatter = bsqFormatter; this.bsqFormatter = bsqFormatter;
} }
@ -94,16 +94,16 @@ public class SupplyView extends ActivatableView<GridPane, Void> implements DaoSt
updateWithBsqBlockChainData(); updateWithBsqBlockChainData();
daoDataChartView.activate(); daoChartView.activate();
daoDataChartView.addListener(this); daoChartView.addListener(this);
daoFacade.addBsqStateListener(this); daoFacade.addBsqStateListener(this);
} }
@Override @Override
protected void deactivate() { protected void deactivate() {
daoDataChartView.removeListener(this); daoChartView.removeListener(this);
daoFacade.removeBsqStateListener(this); daoFacade.removeBsqStateListener(this);
daoDataChartView.deactivate(); daoChartView.deactivate();
} }
@ -134,11 +134,11 @@ public class SupplyView extends ActivatableView<GridPane, Void> implements DaoSt
private void createChart() { private void createChart() {
addTitledGroupBg(root, gridRow, 2, Res.get("dao.factsAndFigures.supply.issuedVsBurnt")); addTitledGroupBg(root, gridRow, 2, Res.get("dao.factsAndFigures.supply.issuedVsBurnt"));
daoDataChartView.initialize(); daoChartView.initialize();
AnchorPane chartPane = new AnchorPane(); AnchorPane chartPane = new AnchorPane();
chartPane.getStyleClass().add("chart-pane"); chartPane.getStyleClass().add("chart-pane");
VBox chartContainer = daoDataChartView.getRoot(); VBox chartContainer = daoChartView.getRoot();
AnchorPane.setTopAnchor(chartContainer, 15d); AnchorPane.setTopAnchor(chartContainer, 15d);
AnchorPane.setBottomAnchor(chartContainer, 10d); AnchorPane.setBottomAnchor(chartContainer, 10d);
AnchorPane.setLeftAnchor(chartContainer, 25d); AnchorPane.setLeftAnchor(chartContainer, 25d);
@ -204,16 +204,16 @@ public class SupplyView extends ActivatableView<GridPane, Void> implements DaoSt
private void updateEconomicsData() { private void updateEconomicsData() {
// We use the supplyDataProvider to get the adjusted data with static historical data as well to use the same // We use the supplyDataProvider to get the adjusted data with static historical data as well to use the same
// monthly scoped data. // monthly scoped data.
Coin issuedAmountFromCompRequests = Coin.valueOf(daoDataModel.getCompensationAmount(fromDate, getToDate())); Coin issuedAmountFromCompRequests = Coin.valueOf(daoChartDataModel.getCompensationAmount(fromDate, getToDate()));
compRequestIssueAmountTextField.setText(bsqFormatter.formatAmountWithGroupSeparatorAndCode(issuedAmountFromCompRequests)); compRequestIssueAmountTextField.setText(bsqFormatter.formatAmountWithGroupSeparatorAndCode(issuedAmountFromCompRequests));
Coin issuedAmountFromReimbursementRequests = Coin.valueOf(daoDataModel.getReimbursementAmount(fromDate, getToDate())); Coin issuedAmountFromReimbursementRequests = Coin.valueOf(daoChartDataModel.getReimbursementAmount(fromDate, getToDate()));
reimbursementAmountTextField.setText(bsqFormatter.formatAmountWithGroupSeparatorAndCode(issuedAmountFromReimbursementRequests)); reimbursementAmountTextField.setText(bsqFormatter.formatAmountWithGroupSeparatorAndCode(issuedAmountFromReimbursementRequests));
Coin totalBurntTradeFee = Coin.valueOf(daoDataModel.getBsqTradeFeeAmount(fromDate, getToDate())); Coin totalBurntTradeFee = Coin.valueOf(daoChartDataModel.getBsqTradeFeeAmount(fromDate, getToDate()));
totalBurntBsqTradeFeeTextField.setText(bsqFormatter.formatAmountWithGroupSeparatorAndCode(totalBurntTradeFee)); totalBurntBsqTradeFeeTextField.setText(bsqFormatter.formatAmountWithGroupSeparatorAndCode(totalBurntTradeFee));
Coin totalProofOfBurnAmount = Coin.valueOf(daoDataModel.getProofOfBurnAmount(fromDate, getToDate())); Coin totalProofOfBurnAmount = Coin.valueOf(daoChartDataModel.getProofOfBurnAmount(fromDate, getToDate()));
totalProofOfBurnAmountTextField.setText(bsqFormatter.formatAmountWithGroupSeparatorAndCode(totalProofOfBurnAmount)); totalProofOfBurnAmountTextField.setText(bsqFormatter.formatAmountWithGroupSeparatorAndCode(totalProofOfBurnAmount));
} }

View File

@ -45,7 +45,7 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
@Singleton @Singleton
public class DaoDataModel { public class DaoChartDataModel {
private final DaoStateService daoStateService; private final DaoStateService daoStateService;
private final Function<Issuance, Long> blockTimeOfIssuanceFunction; private final Function<Issuance, Long> blockTimeOfIssuanceFunction;
private final TemporalAdjusterModel temporalAdjusterModel; private final TemporalAdjusterModel temporalAdjusterModel;
@ -55,7 +55,7 @@ public class DaoDataModel {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Inject @Inject
public DaoDataModel(DaoStateService daoStateService, TemporalAdjusterModel temporalAdjusterModel) { public DaoChartDataModel(DaoStateService daoStateService, TemporalAdjusterModel temporalAdjusterModel) {
super(); super();
this.daoStateService = daoStateService; this.daoStateService = daoStateService;

View File

@ -51,7 +51,7 @@ import java.util.function.Predicate;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
public class DaoDataChartView extends ChartView<DaoDataChartModel> { public class DaoChartView extends ChartView<DaoChartViewModel> {
private static final DecimalFormat priceFormat = new DecimalFormat(",###"); private static final DecimalFormat priceFormat = new DecimalFormat(",###");
private final BsqFormatter bsqFormatter; private final BsqFormatter bsqFormatter;
@ -60,7 +60,7 @@ public class DaoDataChartView extends ChartView<DaoDataChartModel> {
private ListChangeListener<Node> nodeListChangeListener; private ListChangeListener<Node> nodeListChangeListener;
@Inject @Inject
public DaoDataChartView(DaoDataChartModel model, BsqFormatter bsqFormatter) { public DaoChartView(DaoChartViewModel model, BsqFormatter bsqFormatter) {
super(model); super(model);
this.bsqFormatter = bsqFormatter; this.bsqFormatter = bsqFormatter;

View File

@ -17,7 +17,7 @@
package bisq.desktop.main.dao.economy.supply.daodata; package bisq.desktop.main.dao.economy.supply.daodata;
import bisq.desktop.components.chart.ChartModel; import bisq.desktop.components.chart.ChartViewModel;
import bisq.core.dao.state.DaoStateService; import bisq.core.dao.state.DaoStateService;
@ -38,59 +38,59 @@ import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
public class DaoDataChartModel extends ChartModel { public class DaoChartViewModel extends ChartViewModel {
private final DaoStateService daoStateService; private final DaoStateService daoStateService;
private final DaoDataModel daoDataModel; private final DaoChartDataModel daoChartDataModel;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Constructor // Constructor
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Inject @Inject
public DaoDataChartModel(DaoStateService daoStateService, DaoDataModel daoDataModel) { public DaoChartViewModel(DaoStateService daoStateService, DaoChartDataModel daoChartDataModel) {
super(); super();
this.daoStateService = daoStateService; this.daoStateService = daoStateService;
this.daoDataModel = daoDataModel; this.daoChartDataModel = daoChartDataModel;
} }
@Override @Override
protected void applyTemporalAdjuster(TemporalAdjuster temporalAdjuster) { protected void applyTemporalAdjuster(TemporalAdjuster temporalAdjuster) {
daoDataModel.setTemporalAdjuster(temporalAdjuster); daoChartDataModel.setTemporalAdjuster(temporalAdjuster);
} }
@Override @Override
protected TemporalAdjuster getTemporalAdjuster() { protected TemporalAdjuster getTemporalAdjuster() {
return daoDataModel.getTemporalAdjuster(); return daoChartDataModel.getTemporalAdjuster();
} }
List<XYChart.Data<Number, Number>> getBsqTradeFeeChartData(Predicate<Long> predicate) { List<XYChart.Data<Number, Number>> getBsqTradeFeeChartData(Predicate<Long> predicate) {
return toChartData(daoDataModel.getBurnedBsqByMonth(daoStateService.getTradeFeeTxs(), predicate)); return toChartData(daoChartDataModel.getBurnedBsqByMonth(daoStateService.getTradeFeeTxs(), predicate));
} }
List<XYChart.Data<Number, Number>> getCompensationChartData(Predicate<Long> predicate) { List<XYChart.Data<Number, Number>> getCompensationChartData(Predicate<Long> predicate) {
return toChartData(daoDataModel.getMergedCompensationMap(predicate)); return toChartData(daoChartDataModel.getMergedCompensationMap(predicate));
} }
List<XYChart.Data<Number, Number>> getProofOfBurnChartData(Predicate<Long> predicate) { List<XYChart.Data<Number, Number>> getProofOfBurnChartData(Predicate<Long> predicate) {
return toChartData(daoDataModel.getBurnedBsqByMonth(daoStateService.getProofOfBurnTxs(), predicate)); return toChartData(daoChartDataModel.getBurnedBsqByMonth(daoStateService.getProofOfBurnTxs(), predicate));
} }
List<XYChart.Data<Number, Number>> getReimbursementChartData(Predicate<Long> predicate) { List<XYChart.Data<Number, Number>> getReimbursementChartData(Predicate<Long> predicate) {
return toChartData(daoDataModel.getMergedReimbursementMap(predicate)); return toChartData(daoChartDataModel.getMergedReimbursementMap(predicate));
} }
List<XYChart.Data<Number, Number>> getTotalIssuedChartData(Predicate<Long> predicate) { List<XYChart.Data<Number, Number>> getTotalIssuedChartData(Predicate<Long> predicate) {
Map<Long, Long> compensationMap = daoDataModel.getMergedCompensationMap(predicate); Map<Long, Long> compensationMap = daoChartDataModel.getMergedCompensationMap(predicate);
Map<Long, Long> reimbursementMap = daoDataModel.getMergedReimbursementMap(predicate); Map<Long, Long> reimbursementMap = daoChartDataModel.getMergedReimbursementMap(predicate);
Map<Long, Long> sum = daoDataModel.getMergedMap(compensationMap, reimbursementMap, Long::sum); Map<Long, Long> sum = daoChartDataModel.getMergedMap(compensationMap, reimbursementMap, Long::sum);
return toChartData(sum); return toChartData(sum);
} }
List<XYChart.Data<Number, Number>> getTotalBurnedChartData(Predicate<Long> predicate) { List<XYChart.Data<Number, Number>> getTotalBurnedChartData(Predicate<Long> predicate) {
Map<Long, Long> tradeFee = daoDataModel.getBurnedBsqByMonth(daoStateService.getTradeFeeTxs(), predicate); Map<Long, Long> tradeFee = daoChartDataModel.getBurnedBsqByMonth(daoStateService.getTradeFeeTxs(), predicate);
Map<Long, Long> proofOfBurn = daoDataModel.getBurnedBsqByMonth(daoStateService.getProofOfBurnTxs(), predicate); Map<Long, Long> proofOfBurn = daoChartDataModel.getBurnedBsqByMonth(daoStateService.getProofOfBurnTxs(), predicate);
Map<Long, Long> sum = daoDataModel.getMergedMap(tradeFee, proofOfBurn, Long::sum); Map<Long, Long> sum = daoChartDataModel.getMergedMap(tradeFee, proofOfBurn, Long::sum);
return toChartData(sum); return toChartData(sum);
} }
@ -104,7 +104,7 @@ public class DaoDataChartModel extends ChartModel {
} }
long toTimeInterval(Instant ofEpochSecond) { long toTimeInterval(Instant ofEpochSecond) {
return daoDataModel.toTimeInterval(ofEpochSecond); return daoChartDataModel.toTimeInterval(ofEpochSecond);
} }
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////