Search in sources :

Example 1 with ParameterBundle

use of gov.sandia.n2a.parms.ParameterBundle in project n2a by frothga.

the class ParameterSpecGroupPanel method initPanel.

private void initPanel(ParameterSpecGroup group) {
    for (Object key : group.keySet()) {
        ParameterSpecification spec = group.get(key);
        String keyStr = key.toString();
        String[] path = keyStr.split("\\.");
        List<ParameterDomain> d = new ArrayList<ParameterDomain>();
        for (int i = 0; i < path.length - 1; i++) {
            String seg = path[i];
            d.add(new ParameterDomain(seg));
        }
        // , dv, desc,icon);
        Parameter param = new Parameter(path[path.length - 1]);
        ParameterBundle bundle = new ParameterBundle(d, param);
        addParam(bundle, spec);
    }
}
Also used : ConstantParameterSpecification(gov.sandia.umf.platform.ensemble.params.specs.ConstantParameterSpecification) ParameterSpecification(gov.sandia.n2a.parms.ParameterSpecification) UniformParameterSpecification(gov.sandia.umf.platform.ensemble.params.specs.UniformParameterSpecification) EvenSpacingParameterSpecification(gov.sandia.umf.platform.ensemble.params.specs.EvenSpacingParameterSpecification) ParameterDomain(gov.sandia.n2a.parms.ParameterDomain) ArrayList(java.util.ArrayList) Parameter(gov.sandia.n2a.parms.Parameter) ParameterBundle(gov.sandia.n2a.parms.ParameterBundle)

Example 2 with ParameterBundle

use of gov.sandia.n2a.parms.ParameterBundle in project n2a by frothga.

the class OutputParameterPanel method dragGestureRecognized.

public void dragGestureRecognized(DragGestureEvent event) {
    Cursor cursor = null;
    SimpleTree list = (SimpleTree) event.getComponent();
    TreePath[] paths = list.getSelectionPaths();
    if (paths == null) {
        return;
    }
    List<ParameterBundle> bundles = new ArrayList<ParameterBundle>();
    for (TreePath path : paths) {
        List<ParameterDomain> domains = new ArrayList<ParameterDomain>();
        for (int p = 0; p < path.getPathCount(); p++) {
            Object u = ((TNode) path.getPathComponent(p)).getObject();
            if (u instanceof NodeSubdomain) {
                domains.add(((NodeSubdomain) u).getSubdomain());
            }
        }
        NodeBase uLeaf = ((TNode) path.getLastPathComponent()).getObject();
        if (uLeaf instanceof NodeParameter) {
            NodeParameter p = (NodeParameter) uLeaf;
            bundles.add(new ParameterBundle(domains, p.getParameter()));
        } else {
            // TODO: add all children?
            return;
        }
    }
    if (event.getDragAction() == DnDConstants.ACTION_LINK) {
        cursor = DragCursors.getGrabhandcursor();
    }
    event.startDrag(cursor, new TransferableParameterBundles(bundles));
}
Also used : ArrayList(java.util.ArrayList) TransferableParameterBundles(gov.sandia.umf.platform.ui.ensemble.TransferableParameterBundles) ParameterBundle(gov.sandia.n2a.parms.ParameterBundle) Cursor(java.awt.Cursor) SimpleTree(replete.gui.controls.simpletree.SimpleTree) NodeSubdomain(gov.sandia.umf.platform.ui.ensemble.tree.NodeSubdomain) NodeBase(replete.gui.controls.simpletree.NodeBase) TNode(replete.gui.controls.simpletree.TNode) TreePath(javax.swing.tree.TreePath) NodeParameter(gov.sandia.umf.platform.ui.ensemble.tree.NodeParameter) ParameterDomain(gov.sandia.n2a.parms.ParameterDomain)

Example 3 with ParameterBundle

use of gov.sandia.n2a.parms.ParameterBundle in project n2a by frothga.

the class FixedParameterSpacePanel method getSelectedParamsAsBundles.

private List<ParameterBundle> getSelectedParamsAsBundles(TreePath[] paths) {
    List<ParameterBundle> bundles = new ArrayList<ParameterBundle>();
    for (TreePath path : paths) {
        List<ParameterDomain> domains = new ArrayList<ParameterDomain>();
        if (tabParamDomains.getSelectedIndex() == 0) {
            domains.add(new ParameterDomain("Model"));
        } else {
            domains.add(new ParameterDomain("Simulator"));
        }
        for (int p = 0; p < path.getPathCount(); p++) {
            Object u = ((TNode) path.getPathComponent(p)).getObject();
            if (u instanceof NodeSubdomain) {
                domains.add(((NodeSubdomain) u).getSubdomain());
            }
        }
        NodeBase uLeaf = ((TNode) path.getLastPathComponent()).getObject();
        if (uLeaf instanceof NodeParameter) {
            NodeParameter p = (NodeParameter) uLeaf;
            bundles.add(new ParameterBundle(domains, p.getParameter()));
        } else {
            // TODO: add all children?
            return null;
        }
    }
    return bundles;
}
Also used : NodeSubdomain(gov.sandia.umf.platform.ui.ensemble.tree.NodeSubdomain) NodeBase(replete.gui.controls.simpletree.NodeBase) TNode(replete.gui.controls.simpletree.TNode) TreePath(javax.swing.tree.TreePath) NodeParameter(gov.sandia.umf.platform.ui.ensemble.tree.NodeParameter) ArrayList(java.util.ArrayList) ParameterDomain(gov.sandia.n2a.parms.ParameterDomain) ParameterBundle(gov.sandia.n2a.parms.ParameterBundle)

Example 4 with ParameterBundle

use of gov.sandia.n2a.parms.ParameterBundle in project n2a by frothga.

the class FixedParameterSpacePanel method dropIntoGroups.

private void dropIntoGroups(List<ParameterBundle> bundles, Color backgroundHighlight) {
    ParameterSpecGroupPanel pnlGroup = null;
    ParameterSpecPanel pnlSpec = null;
    for (ParameterBundle bundle : bundles) {
        ParameterSpecGroupPanel pnlExistingGroup = pnlGroups.getGroupPanelForParam(bundle);
        if (pnlExistingGroup != null) {
            Dialogs.showWarning(FixedParameterSpacePanel.this, "This parameter already exists in an existing group (" + pnlExistingGroup.getGroupLabel() + ").");
            continue;
        }
        if (pnlGroup == null) {
            pnlGroup = new ParameterSpecGroupPanel();
            new RoundedSpecPanelTargetListener(pnlGroup, backgroundHighlight);
        }
        pnlSpec = pnlGroup.addParam(bundle);
    }
    if (pnlGroup != null) {
        popScrollPane(pnlSpec);
        pnlGroups.addGroupPanel(pnlGroup);
    }
}
Also used : ParameterBundle(gov.sandia.n2a.parms.ParameterBundle)

Example 5 with ParameterBundle

use of gov.sandia.n2a.parms.ParameterBundle in project n2a by frothga.

the class FixedParameterSpacePanel method dragGestureRecognized.

public void dragGestureRecognized(DragGestureEvent event) {
    Cursor cursor = null;
    SimpleTree list = (SimpleTree) event.getComponent();
    TreePath[] paths = list.getSelectionPaths();
    if (paths == null) {
        return;
    }
    List<ParameterBundle> bundles = getSelectedParamsAsBundles(paths);
    if (bundles == null) {
        return;
    }
    if (event.getDragAction() == DnDConstants.ACTION_LINK) {
        cursor = DragCursors.getGrabhandcursor();
    }
    event.startDrag(cursor, new TransferableParameterBundles(bundles));
}
Also used : TreePath(javax.swing.tree.TreePath) ParameterBundle(gov.sandia.n2a.parms.ParameterBundle) Cursor(java.awt.Cursor) SimpleTree(replete.gui.controls.simpletree.SimpleTree)

Aggregations

ParameterBundle (gov.sandia.n2a.parms.ParameterBundle)6 ParameterDomain (gov.sandia.n2a.parms.ParameterDomain)3 ArrayList (java.util.ArrayList)3 TreePath (javax.swing.tree.TreePath)3 NodeParameter (gov.sandia.umf.platform.ui.ensemble.tree.NodeParameter)2 NodeSubdomain (gov.sandia.umf.platform.ui.ensemble.tree.NodeSubdomain)2 Cursor (java.awt.Cursor)2 NodeBase (replete.gui.controls.simpletree.NodeBase)2 SimpleTree (replete.gui.controls.simpletree.SimpleTree)2 TNode (replete.gui.controls.simpletree.TNode)2 Parameter (gov.sandia.n2a.parms.Parameter)1 ParameterSpecification (gov.sandia.n2a.parms.ParameterSpecification)1 ConstantParameterSpecification (gov.sandia.umf.platform.ensemble.params.specs.ConstantParameterSpecification)1 EvenSpacingParameterSpecification (gov.sandia.umf.platform.ensemble.params.specs.EvenSpacingParameterSpecification)1 UniformParameterSpecification (gov.sandia.umf.platform.ensemble.params.specs.UniformParameterSpecification)1 TransferableParameterBundles (gov.sandia.umf.platform.ui.ensemble.TransferableParameterBundles)1