Search in sources :

Example 1 with DQResult

use of org.openlca.core.math.data_quality.DQResult in project olca-app by GreenDelta.

the class ProcessFigure method drawDqBar.

private void drawDqBar(Graphics g) {
    DQResult dqResult = node.parent.editor.dqResult;
    if (!DQUI.displayProcessQuality(dqResult))
        return;
    Point loc = getLocation();
    Dimension size = getSize();
    Color fColor = g.getForegroundColor();
    Color bColor = g.getBackgroundColor();
    g.setForegroundColor(Colors.white());
    g.setBackgroundColor(Colors.white());
    int x = loc.x + size.width - 30;
    int y = loc.y + 10;
    int w = 20;
    DQSystem system = dqResult.setup.processSystem;
    int h = (size.height - 20) / system.indicators.size();
    int[] values = dqResult.get(node.product);
    for (int value : values) {
        Color color = DQUI.getColor(value, system.getScoreCount());
        g.setBackgroundColor(color);
        g.drawRectangle(x, y, w, h);
        g.fillRectangle(x + 1, y + 1, w - 1, h - 1);
        y += h;
    }
    g.setForegroundColor(fColor);
    g.setBackgroundColor(bColor);
}
Also used : DQResult(org.openlca.core.math.data_quality.DQResult) DQSystem(org.openlca.core.model.DQSystem) Color(org.eclipse.swt.graphics.Color) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point)

Example 2 with DQResult

use of org.openlca.core.math.data_quality.DQResult in project olca-app by GreenDelta.

the class CalculationWizard method runCalculation.

private void runCalculation() {
    // for MC simulations, just open the simulation editor
    if (setup.hasType(CalculationType.MONTE_CARLO_SIMULATION)) {
        SimulationEditor.open(setup.calcSetup);
        return;
    }
    boolean upstream = setup.hasType(CalculationType.UPSTREAM_ANALYSIS);
    // run the calculation
    log.trace("run calculation");
    var calc = new SystemCalculator(Database.get());
    var result = upstream ? calc.calculateFull(setup.calcSetup) : calc.calculateContributions(setup.calcSetup);
    // check storage and DQ calculation
    DQResult dqResult = null;
    if (setup.withDataQuality) {
        log.trace("calculate data quality result");
        dqResult = DQResult.of(Database.get(), setup.dqSetup, result);
    }
    // sort and open the editor
    log.trace("sort result items");
    Sort.sort(result);
    log.trace("calculation done; open editor");
    ResultEditor.open(setup.calcSetup, result, dqResult);
}
Also used : DQResult(org.openlca.core.math.data_quality.DQResult) SystemCalculator(org.openlca.core.math.SystemCalculator)

Example 3 with DQResult

use of org.openlca.core.math.data_quality.DQResult in project olca-app by GreenDelta.

the class QuickResultEditor method init.

@Override
public void init(IEditorSite site, IEditorInput iInput) throws PartInitException {
    super.init(site, iInput);
    try {
        var input = (ResultEditorInput) iInput;
        setup = Cache.getAppCache().remove(input.setupKey, CalculationSetup.class);
        result = Cache.getAppCache().remove(input.resultKey, ContributionResult.class);
        resultItems = ResultItemView.of(result);
        Sort.sort(resultItems);
        if (input.dqResultKey != null) {
            dqResult = Cache.getAppCache().remove(input.dqResultKey, DQResult.class);
        }
    } catch (Exception e) {
        log.error("failed to load inventory result", e);
        throw new PartInitException("failed to load inventory result", e);
    }
}
Also used : CalculationSetup(org.openlca.core.model.CalculationSetup) DQResult(org.openlca.core.math.data_quality.DQResult) PartInitException(org.eclipse.ui.PartInitException) PartInitException(org.eclipse.ui.PartInitException) ContributionResult(org.openlca.core.results.ContributionResult)

Aggregations

DQResult (org.openlca.core.math.data_quality.DQResult)3 Dimension (org.eclipse.draw2d.geometry.Dimension)1 Point (org.eclipse.draw2d.geometry.Point)1 Color (org.eclipse.swt.graphics.Color)1 PartInitException (org.eclipse.ui.PartInitException)1 SystemCalculator (org.openlca.core.math.SystemCalculator)1 CalculationSetup (org.openlca.core.model.CalculationSetup)1 DQSystem (org.openlca.core.model.DQSystem)1 ContributionResult (org.openlca.core.results.ContributionResult)1