use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class LabeledComponentPanel method actionPerformed.
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if (command.equals("delete")) {
LinkedList<JComponent> list = new LinkedList<JComponent>();
list.addAll(mySelectedWidgets);
for (JComponent comp : list) {
removeWidget(comp);
}
repackContainingWindow();
} else if (command.equals("add separator")) {
JComponent comp = mySelectedWidgets.iterator().next();
addWidget(new JSeparator(), getComponentIndex(comp) + 1);
repackContainingWindow();
} else if (command.equals("set properties")) {
Window win = SwingUtilities.getWindowAncestor(this);
if (win != null) {
LinkedList<HasProperties> hosts = new LinkedList<HasProperties>();
JComponent lastComp = null;
for (JComponent comp : mySelectedWidgets) {
if (comp instanceof HasProperties) {
hosts.add((HasProperties) comp);
}
lastComp = comp;
}
HostList hostList = new HostList(hosts);
PropertyDialog dialog = PropertyDialog.createDialog(win, "Edit properties", hostList, "OK Cancel");
// PropertyDialog dialog = PropertyDialog.createDialog (
// win, "Edit properties", new PropertyPanel (comp), "OK Cancel");
GuiUtils.locateVertically(dialog, lastComp, GuiUtils.BELOW);
GuiUtils.locateHorizontally(dialog, this, GuiUtils.CENTER);
dialog.setModal(true);
dialog.setVisible(true);
}
} else if (command.equals("reset sliderRange")) {
for (JComponent comp : mySelectedWidgets) {
if (comp instanceof NumericFieldSlider) {
// fix this for regular sliders too?
NumericFieldSlider nslider = (NumericFieldSlider) comp;
nslider.setSliderRange(SliderRange.estimateBoundsIfNecessary(nslider.getRange(), nslider.getDoubleValue()));
}
}
} else if (mySelectedWidgets.size() == 1) {
JComponent comp = mySelectedWidgets.iterator().next();
if (comp instanceof LabeledComponentBase) {
((LabeledComponentBase) comp).actionPerformed(e);
}
} else {
throw new InternalErrorException("Unexpected action: " + e);
}
}
use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class MouseBindings method clone.
public MouseBindings clone() {
MouseBindings bindings;
try {
bindings = (MouseBindings) super.clone();
} catch (Exception e) {
throw new InternalErrorException("MouseBindings cannot be cloned");
}
bindings.myActionMasks = Arrays.copyOf(myActionMasks, myActionMasks.length);
return bindings;
}
use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class SelectionToolbar method setSelectionButtons.
public void setSelectionButtons() {
// create an array of all the selection buttons
ArrayList<JButton> selectionButtons = new ArrayList<JButton>();
selectionButtons.add(selectButton);
selectionButtons.add(ellipticSelectButton);
selectionButtons.add(scaleButton);
selectionButtons.add(transrotateButton);
selectionButtons.add(translateButton);
selectionButtons.add(rotateButton);
selectionButtons.add(constrainedTranslateButton);
selectionButtons.add(pullButton);
// selectionButtons.add (articulatedTransformButton);
// selectionButtons.add(addMarkerButton);
// get the button that is currently selected
SelectionMode mode = main.getSelectionMode();
JButton selectedButton = null;
switch(mode) {
case Select:
{
selectedButton = selectButton;
break;
}
case EllipticSelect:
{
selectedButton = ellipticSelectButton;
break;
}
case Scale:
{
selectedButton = scaleButton;
break;
}
case Translate:
{
selectedButton = translateButton;
break;
}
case Transrotate:
{
selectedButton = transrotateButton;
break;
}
case Rotate:
{
selectedButton = rotateButton;
break;
}
case ConstrainedTranslate:
{
selectedButton = constrainedTranslateButton;
break;
}
case Pull:
{
selectedButton = pullButton;
break;
}
default:
{
throw new InternalErrorException("unimplemented mode " + mode);
}
}
// remove the button that is currently selected from the array list
selectionButtons.remove(selectedButton);
// set the decoration on the selected button
selectedButton.setBorder(bevelBorder);
selectedButton.setBackground(Color.LIGHT_GRAY);
// set the decoration on the unselected buttons
for (JButton b : selectionButtons) {
b.setBorder(border);
b.setBackground(background);
}
}
use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class FemModel3d method findNearestSurfaceElement.
/**
* Returns the nearest surface element to a specified point,
* which is found by projecting the point onto the FEM surface.
* The location of the projection is returned in <code>loc</code>.
*
* @param loc Projected location of the point onto the surface.
* @param pnt Point for which nearest surface element is desired.
* @return Nearest surface element.
*/
public FemElement3d findNearestSurfaceElement(Point3d loc, Point3d pnt) {
Vector2d coords = new Vector2d();
PolygonalMesh surf = getSurfaceMesh();
if (surf == null || surf.numFaces() == 0) {
surf = getInternalSurfaceMesh();
}
if (surf != null) {
Face face = BVFeatureQuery.getNearestFaceToPoint(loc, coords, surf, pnt);
FemElement3d elem = getSurfaceElement(face);
if (elem == null) {
throw new InternalErrorException("surface element not found for face");
}
return elem;
} else {
return null;
}
}
use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class FemElement3d method createIntegrationPoints.
public static IntegrationPoint3d[] createIntegrationPoints(FemElement3d exampleElem, double[] cdata) {
int numi = cdata.length / 4;
IntegrationPoint3d[] pnts = new IntegrationPoint3d[numi];
if (cdata.length != 4 * numi) {
throw new InternalErrorException("Coordinate data length is " + cdata.length + ", expecting " + 4 * numi);
}
for (int k = 0; k < numi; k++) {
pnts[k] = IntegrationPoint3d.create(exampleElem, cdata[k * 4], cdata[k * 4 + 1], cdata[k * 4 + 2], cdata[k * 4 + 3]);
pnts[k].setNumber(k);
}
return pnts;
}
Aggregations