Search in sources :

Example 6 with DataSymbolMetadata

use of cbit.vcell.solver.DataSymbolMetadata in project vcell by virtualcell.

the class DefaultDataIdentifierFilter method accept.

public ArrayList<DataIdentifier> accept(String filterSetName, List<AnnotatedFunction> functionList, DataIdentifier[] filterTheseDataIdentifiers) {
    // 
    if (dataSymbolMetadataResolver != null) {
        ArrayList<String> allFilterNames = new ArrayList<String>();
        if (this.dataSymbolMetadataResolver != null) {
            ModelCategoryType[] uniqueCategories = dataSymbolMetadataResolver.getUniqueFilterCategories();
            for (ModelCategoryType catType : uniqueCategories) {
                allFilterNames.add(catType.getName());
            }
        }
        if (allFilterNames.contains(filterSetName)) {
            ArrayList<DataIdentifier> acceptedDataIdentifiers = new ArrayList<DataIdentifier>();
            for (DataIdentifier dataID : filterTheseDataIdentifiers) {
                DataSymbolMetadata metadata = dataSymbolMetadataResolver.getDataSymbolMetadata(dataID.getName());
                if (metadata != null && metadata.filterCategory.getName().equals(filterSetName)) {
                    String varName = dataID.getName();
                    if (varName.startsWith(MathFunctionDefinitions.Function_regionVolume_current.getFunctionName())) {
                        continue;
                    }
                    if (varName.startsWith(MathFunctionDefinitions.Function_regionArea_current.getFunctionName())) {
                        continue;
                    }
                    acceptedDataIdentifiers.add(dataID);
                }
            }
            return acceptedDataIdentifiers;
        }
    }
    ArrayList<DataIdentifier> acceptedDataIdentifiers = new ArrayList<DataIdentifier>();
    for (int i = 0; i < filterTheseDataIdentifiers.length; i++) {
        if (bPostProcessingMode && filterTheseDataIdentifiers[i].getVariableType().equals(VariableType.POSTPROCESSING)) {
            acceptedDataIdentifiers.add(filterTheseDataIdentifiers[i]);
            continue;
        }
        if (bPostProcessingMode && !filterTheseDataIdentifiers[i].getVariableType().equals(VariableType.POSTPROCESSING)) {
            continue;
        }
        if (!bPostProcessingMode && filterTheseDataIdentifiers[i].getVariableType().equals(VariableType.POSTPROCESSING)) {
            continue;
        }
        String varName = filterTheseDataIdentifiers[i].getName();
        if (varName.startsWith(MathFunctionDefinitions.Function_regionVolume_current.getFunctionName())) {
            continue;
        }
        if (varName.startsWith(MathFunctionDefinitions.Function_regionArea_current.getFunctionName())) {
            continue;
        }
        boolean bSizeVar = varName.startsWith(DiffEquMathMapping.PARAMETER_SIZE_FUNCTION_PREFIX);
        if (filterSetName.equals(REGION_SIZE_FILTER_SET) && bSizeVar) {
            acceptedDataIdentifiers.add(filterTheseDataIdentifiers[i]);
            continue;
        }
        if (!filterSetName.equals(REGION_SIZE_FILTER_SET) && bSizeVar) {
            continue;
        }
        if (filterSetName.equals(ALL)) {
            acceptedDataIdentifiers.add(filterTheseDataIdentifiers[i]);
        } else if (filterSetName.equals(VOLUME_FILTER_SET) && filterTheseDataIdentifiers[i].getVariableType().getVariableDomain().equals(VariableDomain.VARIABLEDOMAIN_VOLUME)) {
            acceptedDataIdentifiers.add(filterTheseDataIdentifiers[i]);
        } else if (filterSetName.equals(MEMBRANE_FILTER_SET) && filterTheseDataIdentifiers[i].getVariableType().getVariableDomain().equals(VariableDomain.VARIABLEDOMAIN_MEMBRANE)) {
            acceptedDataIdentifiers.add(filterTheseDataIdentifiers[i]);
        } else if (filterSetName.equals(USER_DEFINED_FILTER_SET)) {
            if (functionList != null) {
                for (AnnotatedFunction f : functionList) {
                    if (!f.isPredefined() && f.getName().equals(varName)) {
                        acceptedDataIdentifiers.add(filterTheseDataIdentifiers[i]);
                        break;
                    }
                }
            }
        }
    }
    if (acceptedDataIdentifiers.size() > 0) {
        return acceptedDataIdentifiers;
    }
    return null;
}
Also used : DataIdentifier(cbit.vcell.simdata.DataIdentifier) ModelCategoryType(cbit.vcell.solver.SimulationModelInfo.ModelCategoryType) ArrayList(java.util.ArrayList) DataSymbolMetadata(cbit.vcell.solver.DataSymbolMetadata) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction)

Example 7 with DataSymbolMetadata

use of cbit.vcell.solver.DataSymbolMetadata in project vcell by virtualcell.

the class PlotPane method updateLegend.

/**
 * Comment
 */
private void updateLegend() {
    Plot2D plot = getPlot2DPanel1().getPlot2D();
    SymbolTableEntry[] steList = plot.getSymbolTableEntries();
    DataSymbolMetadataResolver metadataResolver = plot.getDataSymbolMetadataResolver();
    String[] plotLabels = plot.getVisiblePlotColumnTitles();
    int[] plotIndices = plot.getVisiblePlotIndices();
    Component[] legends = getJPanelPlotLegends().getComponents();
    // add legends if necessarry
    if (ml == null) {
        ml = new java.awt.event.MouseAdapter() {

            public void mouseClicked(java.awt.event.MouseEvent evt) {
                String name = ((JLabel) evt.getSource()).getText();
                getPlot2DPanel1().setCurrentPlot(name);
            }
        };
    }
    for (int i = 0; i < plotIndices.length - legends.length / 2; i++) {
        JLabel line = new JLabel();
        JLabel text = new JLabel();
        line.setBorder(new EmptyBorder(6, 0, 0, 0));
        text.setBorder(new EmptyBorder(0, 8, 6, 0));
        getJPanelPlotLegends().add(line);
        getJPanelPlotLegends().add(text);
        text.addMouseListener(ml);
    }
    legends = getJPanelPlotLegends().getComponents();
    // update labels and show them,use reverse loop to generate non-repeatable colors
    for (int i = (plotIndices.length - 1); i >= 0; i--) {
        LineIcon icon = new LineIcon(getPlot2DPanel1().getVisiblePlotPaint(i));
        String plotLabel = null;
        if (plot instanceof SingleXPlot2D) {
            plotLabel = plotLabels[i + 1];
        } else {
            plotLabel = plotLabels[2 * i + 1];
        }
        ((JLabel) legends[2 * i]).setIcon(icon);
        final int head = 20;
        final int tail = 0;
        String tooltipString = "";
        String unitSymbol = "";
        if (metadataResolver != null) {
            DataSymbolMetadata metaData = metadataResolver.getDataSymbolMetadata(plotLabel);
            if (metaData != null && metaData.unit != null) {
                VCUnitDefinition ud = metaData.unit;
                if (ud != null) {
                    unitSymbol += ud.getSymbolUnicode();
                }
            }
            if (metaData != null && metaData.tooltipString != null) {
                tooltipString = metaData.tooltipString;
            }
        }
        String shortLabel = plotLabel;
        if (shortLabel.length() > head + 3 + tail) {
            shortLabel = shortLabel.substring(0, head) + "..." + shortLabel.substring(shortLabel.length() - tail, shortLabel.length());
        }
        // shortLabel = "<html>" + shortLabel + "<font color=\"red\">" + " [" + unitSymbol + "] " + "</font></html>";
        shortLabel = "<html>" + shortLabel + "<font color=\"#8B0000\">" + " [" + unitSymbol + "] " + "</font></html>";
        tooltipString = "<html>" + plotLabel + "<font color=\"#0000FF\">" + " " + tooltipString + " " + "</font></html>";
        ((JLabel) legends[2 * i + 1]).setText(shortLabel);
        ((JLabel) legends[2 * i + 1]).setToolTipText(tooltipString);
        legends[2 * i].setVisible(true);
        legends[2 * i + 1].setVisible(true);
    }
    // if extra ones, hide them
    for (int i = 2 * plotIndices.length; i < legends.length; i++) {
        legends[i].setVisible(false);
    }
}
Also used : DataSymbolMetadataResolver(cbit.vcell.solver.SimulationModelInfo.DataSymbolMetadataResolver) JLabel(javax.swing.JLabel) EnhancedJLabel(org.vcell.util.gui.EnhancedJLabel) Paint(java.awt.Paint) SingleXPlot2D(cbit.plot.SingleXPlot2D) DataSymbolMetadata(cbit.vcell.solver.DataSymbolMetadata) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) SingleXPlot2D(cbit.plot.SingleXPlot2D) Plot2D(cbit.plot.Plot2D) Component(java.awt.Component) EmptyBorder(javax.swing.border.EmptyBorder)

Aggregations

DataSymbolMetadata (cbit.vcell.solver.DataSymbolMetadata)7 ColumnDescription (cbit.vcell.util.ColumnDescription)3 Component (java.awt.Component)3 FunctionColumnDescription (cbit.vcell.math.FunctionColumnDescription)2 DataIdentifier (cbit.vcell.simdata.DataIdentifier)2 DataSymbolMetadataResolver (cbit.vcell.solver.SimulationModelInfo.DataSymbolMetadataResolver)2 ModelCategoryType (cbit.vcell.solver.SimulationModelInfo.ModelCategoryType)2 ArrayList (java.util.ArrayList)2 DefaultListCellRenderer (javax.swing.DefaultListCellRenderer)2 JLabel (javax.swing.JLabel)2 JList (javax.swing.JList)2 Plot2D (cbit.plot.Plot2D)1 SingleXPlot2D (cbit.plot.SingleXPlot2D)1 ODEDataInterface (cbit.vcell.client.data.ODEDataInterface)1 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)1 SymbolTableEntry (cbit.vcell.parser.SymbolTableEntry)1 AnnotatedFunction (cbit.vcell.solver.AnnotatedFunction)1 SimulationModelInfo (cbit.vcell.solver.SimulationModelInfo)1 VCUnitDefinition (cbit.vcell.units.VCUnitDefinition)1 Paint (java.awt.Paint)1