use of maspack.properties.PropertyInfo in project artisynth_core by artisynth.
the class SelectionPopup method addPropertyEditMenuItems.
public void addPropertyEditMenuItems(LinkedList<ModelComponent> selection) {
// parse the selection list.
boolean allSelectedHaveProperties = false;
boolean allSelectedAreTraceable = false;
int tracingCnt = 0;
boolean oneSelectedIsRenderable = false;
boolean oneSelectedHasRenderProps = false;
boolean oneSelectedHasFixedRenderProps = false;
boolean oneSelectedIsVisible = false;
boolean oneSelectedIsInvisible = false;
boolean oneSelectedHasRenderPropsProperty = false;
if (selection.size() > 0) {
allSelectedHaveProperties = true;
allSelectedAreTraceable = true;
for (ModelComponent c : selection) {
if (c instanceof RenderableComponent) {
oneSelectedIsRenderable = true;
RenderableComponent rcomp = (RenderableComponent) c;
if (isVisible(rcomp)) {
oneSelectedIsVisible = true;
} else {
oneSelectedIsInvisible = true;
}
// RenderableComponent > HasProperties, but may not have
// renderProps property
PropertyInfo rinfo = rcomp.getAllPropertyInfo().get("renderProps");
if (rinfo != null) {
oneSelectedHasRenderPropsProperty = true;
}
if (rcomp.getRenderProps() != null) {
oneSelectedHasRenderProps = true;
// be set to null ...
if (!oneSelectedHasFixedRenderProps) {
if (!rinfo.getNullValueOK()) {
oneSelectedHasFixedRenderProps = true;
}
}
}
}
if (!(c instanceof HasProperties)) {
allSelectedHaveProperties = false;
}
if (!(c instanceof Traceable)) {
allSelectedAreTraceable = false;
}
}
}
Collection<Traceable> traceSet = myMain.getRootModel().getTraceSet();
for (Traceable tr : traceSet) {
if (tr instanceof ModelComponent && ((ModelComponent) tr).isSelected()) {
tracingCnt++;
}
}
if (allSelectedHaveProperties) {
addMenuItem("Edit properties ...");
}
if (oneSelectedIsRenderable && oneSelectedHasRenderPropsProperty) {
if (oneSelectedHasRenderProps) {
addMenuItem("Edit render props ...");
if (!oneSelectedHasFixedRenderProps) {
addMenuItem("Clear render props");
}
} else {
addMenuItem("Set render props ...");
}
}
if (oneSelectedIsInvisible) {
addMenuItem("Set visible");
}
if (oneSelectedIsVisible) {
addMenuItem("Set invisible");
}
if (allSelectedAreTraceable) {
if (selection.size() - tracingCnt > 0) {
addMenuItem("Enable tracing");
}
if (tracingCnt > 0) {
addMenuItem("Disable tracing");
}
JMenuItem menuItem = new JMenuItem("Clear trace");
menuItem.addActionListener(this);
String[] commonTraceables = getCommonTraceables(selection);
if (commonTraceables.length > 0) {
menuItem = new JMenuItem("Add tracing probe");
myTraceItem = menuItem;
}
menuItem.addActionListener(this);
add(menuItem);
}
}
use of maspack.properties.PropertyInfo in project artisynth_core by artisynth.
the class PropertyWidgetDialog method valueChange.
public void valueChange(ValueChangeEvent e) {
if (e.getSource() == myPropField) {
PropertyInfo info = myPropField.getPropertyInfo();
ModelComponent comp = myPropField.getModelComponent();
if (info != null && PropertyWidget.canCreateWithSlider(info)) {
mySliderSelector.setEnabledAll(true);
mySliderSelector.setValue(true);
updateRange(comp, info);
} else {
mySliderSelector.setValue(false);
mySliderSelector.setEnabledAll(false);
}
if (info != null && comp != null) {
myOKButton.setEnabled(true);
myLabelTextField.setEnabledAll(true);
myLabelTextField.setValue(info.getName());
} else {
myOKButton.setEnabled(false);
myLabelTextField.setEnabledAll(false);
myLabelTextField.setValue(null);
}
} else if (e.getSource() == mySliderSelector) {
boolean sliderChoosen = (Boolean) mySliderSelector.getValue();
myRangeField.setEnabledAll(sliderChoosen);
}
}
Aggregations