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;
@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 SplitPane splitPane;
protected final NumberAxis xAxis;
@ -194,11 +194,11 @@ public abstract class ChartView<T extends ChartModel> extends ActivatableView<VB
dividerNodes.forEach(node -> node.setOnMouseReleased(null));
}
public void addListener(ChartModel.Listener listener) {
public void addListener(ChartViewModel.Listener listener) {
model.addListener(listener);
}
public void removeListener(ChartModel.Listener listener) {
public void removeListener(ChartViewModel.Listener listener) {
model.removeListener(listener);
}

View File

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

View File

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

View File

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

View File

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