private void makeAppTab() { appearancePanel = new JPanel(new BorderLayout()); Box appBox = new Box(BoxLayout.Y_AXIS); int topSpacing = 0; int bottomSpacing = 5; Border boxBorder = new EmptyBorder(topSpacing, 5, bottomSpacing, 5); Border sliderBoxBorder = new EmptyBorder(topSpacing, 10, bottomSpacing, 10); // lines lineColorChooser = new SimpleColorChooser(); lineColorChooser.setBorder(new EmptyBorder(8, 8, 8, 8)); lineColorChooser.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { setLineColor(lineColorChooser.getColor()); } }); lineColorChooser.addActionListener(closeListener); Box lineBox = new Box(BoxLayout.Y_AXIS); lineBox.setBorder( new CompoundBorder(new EmptyBorder(5, 5, 5, 5), LineBorder.createGrayLineBorder())); Box lineButtonBox = new Box(BoxLayout.X_AXIS); lineButtonBox.setBorder(boxBorder); showLines = new JCheckBox("lines"); showLines.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setShowLines(showLines.isSelected()); } }); lineButtonBox.add(showLines); linesReflecting = new JCheckBox("reflection"); linesReflecting.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setLinesReflecting(isLinesReflecting()); } }); lineButtonBox.add(linesReflecting); lineReflectionSlider = new JSlider(SwingConstants.HORIZONTAL, 0, 100, 0); lineReflectionSlider.setPreferredSize(new Dimension(70, 20)); lineReflectionSlider.setBorder(new EmptyBorder(0, 5, 0, 0)); lineReflectionSlider.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { setLineReflection(getLineReflection()); } }); lineButtonBox.add(lineReflectionSlider); JButton lineColorButton = new JButton("color"); lineColorButton.setMargin(new Insets(0, 5, 0, 5)); lineColorButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { switchToLineColorChooser(); } }); lineBox.add(lineButtonBox); Box tubeRadiusBox = new Box(BoxLayout.X_AXIS); tubeRadiusBox.setBorder(sliderBoxBorder); tubeRadiusBox.add(lineColorButton); tubeRadiusBox.add(Box.createHorizontalStrut(7)); JLabel tubeRadiusLabel = new JLabel("radius"); tubeRadiusSlider = new JSlider(SwingConstants.HORIZONTAL, 0, 100, 0); tubeRadiusSlider.setPreferredSize(new Dimension(70, 20)); tubeRadiusSlider.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent arg0) { setTubeRadius(getTubeRadius()); } }); tubeRadiusBox.add(tubeRadiusLabel); tubeRadiusBox.add(tubeRadiusSlider); tubes = new JCheckBox("tubes"); tubes.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { setTubes(tubes.isSelected()); } }); tubeRadiusBox.add(tubes); lineBox.add(tubeRadiusBox); appBox.add(lineBox); // points pointColorChooser = new SimpleColorChooser(); pointColorChooser.setBorder(new EmptyBorder(8, 8, 8, 8)); pointColorChooser.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { setPointColor(pointColorChooser.getColor()); } }); pointColorChooser.addActionListener(closeListener); Box pointBox = new Box(BoxLayout.Y_AXIS); pointBox.setBorder( new CompoundBorder(new EmptyBorder(5, 5, 5, 5), LineBorder.createGrayLineBorder())); Box pointButtonBox = new Box(BoxLayout.X_AXIS); pointButtonBox.setBorder(boxBorder); showPoints = new JCheckBox("points"); showPoints.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { setShowPoints(showPoints.isSelected()); } }); pointButtonBox.add(showPoints); pointsReflecting = new JCheckBox("reflection"); pointsReflecting.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setPointsReflecting(isPointsReflecting()); } }); pointButtonBox.add(pointsReflecting); pointReflectionSlider = new JSlider(SwingConstants.HORIZONTAL, 0, 100, 0); pointReflectionSlider.setPreferredSize(new Dimension(70, 20)); pointReflectionSlider.setBorder(new EmptyBorder(0, 5, 0, 0)); pointReflectionSlider.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { setPointReflection(getPointReflection()); } }); pointButtonBox.add(pointReflectionSlider); JButton pointColorButton = new JButton("color"); pointColorButton.setMargin(new Insets(0, 5, 0, 5)); pointColorButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { switchToPointColorChooser(); } }); pointBox.add(pointButtonBox); Box pointRadiusBox = new Box(BoxLayout.X_AXIS); pointRadiusBox.setBorder(sliderBoxBorder); pointRadiusBox.add(pointColorButton); pointRadiusBox.add(Box.createHorizontalStrut(7)); JLabel pointRadiusLabel = new JLabel("radius"); pointRadiusSlider = new JSlider(SwingConstants.HORIZONTAL, 0, 100, 0); pointRadiusSlider.setPreferredSize(new Dimension(70, 20)); pointRadiusSlider.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent arg0) { setPointRadius(0.01 * pointRadiusSlider.getValue()); } }); pointRadiusBox.add(pointRadiusLabel); pointRadiusBox.add(pointRadiusSlider); spheres = new JCheckBox("spheres"); spheres.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { setSpheres(spheres.isSelected()); } }); pointRadiusBox.add(spheres); pointBox.add(pointRadiusBox); appBox.add(pointBox); // faces faceColorChooser = new SimpleColorChooser(); faceColorChooser.setBorder(new EmptyBorder(8, 8, 8, 8)); faceColorChooser.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { setFaceColor(faceColorChooser.getColor()); } }); faceColorChooser.addActionListener(closeListener); Box faceBox = new Box(BoxLayout.Y_AXIS); faceBox.setBorder( new CompoundBorder(new EmptyBorder(5, 5, 5, 5), LineBorder.createGrayLineBorder())); Box faceButtonBox = new Box(BoxLayout.X_AXIS); faceButtonBox.setBorder(boxBorder); showFaces = new JCheckBox("faces"); showFaces.setSelected(true); showFaces.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { setShowFaces(showFaces.isSelected()); } }); faceButtonBox.add(showFaces); facesReflecting = new JCheckBox("reflection"); facesReflecting.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setFacesReflecting(isFacesReflecting()); } }); faceButtonBox.add(facesReflecting); faceReflectionSlider = new JSlider(SwingConstants.HORIZONTAL, 0, 100, 0); faceReflectionSlider.setPreferredSize(new Dimension(70, 20)); faceReflectionSlider.setBorder(new EmptyBorder(0, 5, 0, 0)); faceReflectionSlider.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { setFaceReflection(getFaceReflection()); } }); faceButtonBox.add(faceReflectionSlider); JButton faceColorButton = new JButton("color"); faceColorButton.setMargin(new Insets(0, 5, 0, 5)); faceColorButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { switchToFaceColorChooser(); } }); faceBox.add(faceButtonBox); Box transparencyBox = new Box(BoxLayout.X_AXIS); transparencyBox.setBorder(new EmptyBorder(topSpacing, 5, 0, 10)); transparencyBox.add(faceColorButton); transparencyBox.add(Box.createHorizontalStrut(7)); transparencySlider = new JSlider(SwingConstants.HORIZONTAL, 0, 100, 1); transparencySlider.setPreferredSize(new Dimension(70, 20)); transparencySlider.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent arg0) { setTransparency(getTransparency()); } }); transparencyBox.add(transparencySlider); transparency = new JCheckBox("transp"); transparency.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { setTransparencyEnabled(transparency.isSelected()); } }); transparencyBox.add(transparency); faceBox.add(transparencyBox); JPanel flatPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); // flatPanel.setBorder(new EmptyBorder(5,5,5,5)); facesFlat = new JCheckBox("flat shading"); facesFlat.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setFacesFlat(isFacesFlat()); } }); flatPanel.add(facesFlat); faceBox.add(flatPanel); appBox.add(faceBox); appearancePanel.add(appBox); }
public void setLineColor(Color c) { lineColorChooser.setColor(c); String attribute = CommonAttributes.LINE_SHADER + "." + CommonAttributes.DIFFUSE_COLOR; getAppearance().setAttribute(attribute, c); }
public void setFaceColor(Color c) { faceColorChooser.setColor(c); String attribute = CommonAttributes.POLYGON_SHADER + "." + CommonAttributes.DIFFUSE_COLOR; getAppearance().setAttribute(attribute, c); }
public void setPointColor(Color c) { pointColorChooser.setColor(c); String attribute = CommonAttributes.POINT_SHADER + "." + CommonAttributes.DIFFUSE_COLOR; getAppearance().setAttribute(attribute, c); }