@Override public void adjustmentValueChanged(final AdjustmentEvent e) { final Content content = univ.getSelected(); if (null == content) { Utils.log("Nothing selected!"); return; } Color3f color = content.getColor(); if (null == color) color = new Color3f(1, 1, 0); // default to yellow final float[] co = new float[3]; color.get(co); co[k] = e.getValue() / 255.0f; content.setColor(new Color3f(co)); typer.setText(Integer.toString(e.getValue())); } });
@Override public void contentSelected(final Content arg0) { if (null == arg0) { return; } Color3f color = arg0.getColor(); if (null == color) color = new Color3f(1, 1, 0); // default to yellow final float[] co = new float[3]; color.get(co); for (int i=0; i<3; ++i) { // Disallow the slider from firing an event when its value is adjusted sliders[i].setValueIsAdjusting(true); final int val = (int)(co[i] * 255); typers[i].setText(Integer.toString(val)); sliders[i].setValue(val); } // After all are set, re-enable, which triggers events (the color will be set three times...) for (int i=0; i<3; ++i) { sliders[i].setValueIsAdjusting(false); } // Alpha slider: alphaSlider.setValueIsAdjusting(true); final int alpha = (int)((1 - arg0.getTransparency()) * 255); alphaTyper.setText(Integer.toString(alpha)); alphaSlider.setValue(alpha); alphaSlider.setValueIsAdjusting(false); }
final Content c = (Content) content; final Mesh m = new Mesh(ctm, c.getName(), c.getColor(), c.getTransparency()); m.getMinMax(min, max); meshes.add(m);