fhshdadsofijdfaoikj

jjdfolsijowerdihjndfowsihjnfvdsoij
 avatar
user_9487184
java
2 years ago
2.1 kB
3
Indexable
Never
 /*-------------------------------------------------------------------- */
    /*metodi da utili alla gui */
    /*la chiave del pair rappresenta le coordinate dei brick */
    @Override
    public Map<Pair<Double, Double>, Optional<Integer>> getBrickList() {
        return this.model.getBrickList().entrySet().stream().collect(
            Collectors.toMap(
                m-> new Pair<>(
                    m.getKey().getX()* this.delta().getX(),
                    m.getKey().getY()*this.delta().getY()),
                m->m.getValue()));
    }

    @Override
    public Pair<Double, Double> getBrickDimension() {
        return new Pair<Double,Double>(
            this.model.getBrickDimension().getX() * this.delta().getX(),
            this.model.getBrickDimension().getY() * this.delta().getY()
        );
    }

    @Override
    public Pair<Double, Double> getBall() {
        return new Pair<Double,Double>(
            this.model.getBall().getX()*this.delta().getX(),
            this.model.getBall().getY()*this.delta().getY()
        );
    }

    @Override
    public Pair<Double, Double> getPadPos() {
        return new Pair<Double,Double>(
            this.model.getPad().getX()* this.delta().getX(),
            this.model.getPad().getY()* this.delta().getY()
        );
    }

    @Override
    public Double getPadWight(){
        return this.model.getPadWight()*this.delta().getX();
    }

    @Override
    public Double getPadHeight(){
        return this.model.getPadHeight()* this.delta().getY();
    }

    @Override
    public Double getRBall(){
        var dt = this.delta().getX()<this.delta().getY()? this.delta().getX():this.delta().getY();
        return this.model.getRBall()*dt;
    }
    /*calcolo il delta di proiezione che c'e
     * fra il mondo e la sua vista
     */
    private Pair<Double,Double> delta(){
        return new Pair<Double,Double>(
            uiContr.windowDim().getX()/this.getWorldDimension().getX(),
            uiContr.windowDim().getY()/this.getWorldDimension().getY());
    }