use of maspack.util.Range in project artisynth_core by artisynth.
the class SetHandler method create.
public static LabeledComponentBase create(Property prop, double min, double max) {
String name = prop.getName();
PropertyInfo info = prop.getInfo();
Class<?> type = info.getValueClass();
LabeledComponentBase widget = null;
if (type == double.class || type == float.class || type == Double.class || type == Float.class) {
DoubleFieldSlider doubleSlider = new DoubleFieldSlider(name, min, max);
if (info.getPrintFormat() != null) {
doubleSlider.setFormat(info.getPrintFormat());
}
Range range = prop.getRange();
if (range instanceof NumericInterval) {
NumericInterval nrange = (NumericInterval) range;
doubleSlider.setRange(nrange);
if (nrange.isBounded()) {
doubleSlider.setSliderRange(nrange);
}
}
GuiUtils.setFixedWidth(doubleSlider.getTextField(), 100);
doubleSlider.addValueChangeListener(new PropChangeListener(prop));
widget = doubleSlider;
} else if (type == int.class || type == Integer.class) {
IntegerFieldSlider intSlider = new IntegerFieldSlider(name, (int) min, (int) max);
Range range = prop.getRange();
if (range instanceof IntegerInterval) {
IntegerInterval irange = (IntegerInterval) range;
intSlider.setRange(irange);
if (irange.isBounded()) {
intSlider.setSliderRange(irange);
}
// intSlider.setSliderRange ((IntRange)range);
}
GuiUtils.setFixedWidth(intSlider.getTextField(), 100);
intSlider.addValueChangeListener(new PropChangeListener(prop));
widget = intSlider;
}
if (widget != null) {
widget.setToolTipText(info.getDescription());
finishWidget(widget, prop);
}
return widget;
}
use of maspack.util.Range in project artisynth_core by artisynth.
the class SetHandler method createWidget.
protected static LabeledComponentBase createWidget(Property prop) {
PropertyInfo info = prop.getInfo();
Class<?> type = info.getValueClass();
if (String.class.isAssignableFrom(type)) {
Range range = prop.getRange();
if (info.isReadOnly() || range == null || !(range instanceof StringRange) || ((StringRange) range).isWildcard()) {
return new StringField();
} else {
return new StringSelector();
}
} else if (type == double.class || type == float.class || type == Double.class || type == Float.class) {
return new DoubleField();
} else if (type == int.class || type == Integer.class) {
return new IntegerField();
} else if (type == boolean.class || type == Boolean.class) {
if (info.isReadOnly()) {
return new StringField();
} else {
return new BooleanSelector();
}
} else if (VectorBase.class.isAssignableFrom(type)) {
if (VectorNd.class.isAssignableFrom(type) || info.getDimension() == -1) {
return new VariableVectorField();
} else {
return new VectorField();
}
} else if (VectoriBase.class.isAssignableFrom(type) && info.getDimension() != -1) {
return new VectoriField();
} else if (SymmetricMatrix3d.class.isAssignableFrom(type)) {
return new SymmetricMatrix3dField();
} else if (RigidTransform3d.class.isAssignableFrom(type)) {
return new RigidTransformWidget();
} else if (AffineTransform3d.class.isAssignableFrom(type)) {
return new AffineTransformWidget();
} else // }
if (Rectangle2d.class.isAssignableFrom(type)) {
return new RectangleField();
} else if (AxisAngle.class.isAssignableFrom(type)) {
return new AxisAngleField();
} else if (Enum.class.isAssignableFrom(type)) {
if (info.isReadOnly()) {
return new StringField();
} else {
return new EnumSelector();
}
} else if (Color.class.isAssignableFrom(type)) {
return new ColorSelector();
} else if (IntegerInterval.class.isAssignableFrom(type)) {
return new IntegerIntervalField();
} else if (NumericInterval.class.isAssignableFrom(type)) {
return new DoubleIntervalField();
} else if (GLGridResolution.class.isAssignableFrom(type)) {
return new GridResolutionField();
} else if (Font.class.isAssignableFrom(type)) {
return new FontField();
} else if (CompositeProperty.class.isAssignableFrom(type)) {
Class<?>[] subclasses = PropertyUtils.findCompositePropertySubclasses(type);
if (subclasses != null) {
return new CompositePropertyPanel();
} else {
return new CompositePropertyWidget();
}
// if (info.getWidgetType() == PropertyInfo.WidgetType.Panel) {
// return new CompositePropertyWidget();
// }
// else {
// return new CompositePropertyWidget();
// }
} else {
return null;
}
}
Aggregations