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;
}
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);
}
}
Aggregations