use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.
the class MuscleElementDesc method render.
public void render(Renderer renderer, RenderProps props, int flags) {
double widgetSize = 0;
double directionLength = 0;
ModelComponent gparent = getGrandParent();
DirectionRenderType renderType = DirectionRenderType.ELEMENT;
if (gparent instanceof MuscleBundle) {
MuscleBundle bundle = (MuscleBundle) gparent;
widgetSize = bundle.getElementWidgetSize();
directionLength = bundle.getDirectionRenderLen();
renderType = bundle.getDirectionRenderType();
}
if (widgetSize != 0) {
Shading savedShading = renderer.setPropsShading(props);
if (myWidgetColor != null) {
renderer.setFaceColoring(props, myWidgetColor, isSelected());
} else {
renderer.setFaceColoring(props, isSelected());
}
myElement.renderWidget(renderer, widgetSize, props);
renderer.setShading(savedShading);
}
if (directionLength > 0) {
Matrix3d F = new Matrix3d();
Vector3d dir = new Vector3d();
float[] coords0 = new float[3];
float[] coords1 = new float[3];
renderDirection(renderer, props, coords0, coords1, F, dir, directionLength, renderType);
}
}
use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.
the class MuscleElementDescList method dorender.
private void dorender(Renderer renderer, int flags, boolean selected) {
// This code is taken mostly verbatim from FemElement3dList.
// Should find a way to avoid duplicate code ...
boolean selecting = renderer.isSelecting();
double directionLength = 0;
ModelComponent parent = getParent();
MuscleBundle.DirectionRenderType renderType = MuscleBundle.DirectionRenderType.ELEMENT;
if (parent instanceof MuscleBundle) {
MuscleBundle bundle = (MuscleBundle) parent;
directionLength = bundle.getDirectionRenderLen();
renderType = bundle.getDirectionRenderType();
}
if (directionLength > 0) {
renderDirections(renderer, directionLength, renderType, selected);
}
}
use of artisynth.core.modelbase.ModelComponent 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);
}
}
use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.
the class PropertyWidgetDialog method createWidget.
public LabeledComponentBase createWidget() {
if (getModelComponent() == null || getPropertyInfo() == null) {
throw new IllegalStateException("component and/or property not set");
}
LabeledComponentBase widget;
ModelComponent comp = getModelComponent();
String propPath = getPropertyPath();
Property prop = comp.getProperty(propPath);
if (prop == null) {
throw new InternalErrorException("property '" + propPath + "' not found for component " + comp.getClass());
}
if (CompositeProperty.class.isAssignableFrom(prop.getInfo().getValueClass())) {
// replace prop with an EditingProperty, since
// CompositePropertyWidgets only work properly with those
prop = createEditingProperty(prop);
}
if (isSliderSelected()) {
widget = PropertyWidget.create(prop, getSliderMinimum(), getSliderMaximum());
} else {
widget = PropertyWidget.create(prop);
}
String labelText = myLabelTextField.getStringValue();
widget.setLabelText(labelText);
if (!myLabelFontColorSelector.valueIsNull()) {
widget.setLabelFontColor(myLabelFontColorSelector.getColor());
}
if (!myBackgroundColorSelector.valueIsNull()) {
widget.setBackgroundColor(myBackgroundColorSelector.getColor());
}
return widget;
}
use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.
the class SelectableComponentPanel method mapWidgetToComponent.
public void mapWidgetToComponent(JComponent widget, ModelComponent comp) {
if (getComponentIndex(widget) == -1) {
throw new IllegalArgumentException("Widget " + widget + " not present in panel");
}
if (comp == null) {
ModelComponent oldComp = myWidgetComponentMap.remove(widget);
if (oldComp != null) {
myComponentWidgetMap.remove(oldComp);
}
} else {
myWidgetComponentMap.put(widget, comp);
myComponentWidgetMap.put(comp, widget);
}
}
Aggregations