Mtl(final float alpha, final Color3f c) { this.alpha = alpha; final float[] f = new float[3]; c.get(f); this.R = f[0]; this.G = f[1]; this.B = f[2]; name = "mat_" + mat_index; mat_index++; }
@Override public void colorChanged(final Color3f color) { background.setColor(color); status.setBackground(color.get()); ((ImageCanvas3D) univ.getCanvas()).render(); }
void saveContentInstant(final PrintWriter out, final ContentInstant c) { c.color == null ? null : Integer.toString(c.color.get().getRGB());
@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); }