001: /*
002: * $Header: /cvs/j3dfly/J3dFly/src/org/jdesktop/j3dfly/utils/environment/J3dSkyControlPanel.java,v 1.1 2005/04/20 21:04:53 paulby Exp $
003: *
004: * Sun Public License Notice
005: *
006: * The contents of this file are subject to the Sun Public License Version
007: * 1.0 (the "License"). You may not use this file except in compliance with
008: * the License. A copy of the License is available at http://www.sun.com/
009: *
010: * The Original Code is Java 3D(tm) Fly Through.
011: * The Initial Developer of the Original Code is Paul Byrne.
012: * Portions created by Paul Byrne are Copyright (C) 2002.
013: * All Rights Reserved.
014: *
015: * Contributor(s): Paul Byrne.
016: *
017: **/
018: package org.jdesktop.j3dfly.utils.environment;
019:
020: /**
021: *
022: * @author paulby
023: * @version
024: */
025: public class J3dSkyControlPanel extends javax.swing.JPanel implements
026: SkyTimeListener {
027:
028: private J3dSky sky;
029:
030: /** Creates new form J3dSkyControlPanel */
031: public J3dSkyControlPanel(J3dSky sky) {
032: this .sky = sky;
033: initComponents();
034:
035: showSkyCB.setSelected(sky.isEnabled());
036: sky.addTimeChangeListener(this );
037: }
038:
039: /** This method is called from within the constructor to
040: * initialize the form.
041: * WARNING: Do NOT modify this code. The content of this method is
042: * always regenerated by the FormEditor.
043: */
044: private void initComponents() {//GEN-BEGIN:initComponents
045: skyTimeSlider = new javax.swing.JSlider();
046: java.util.Hashtable labels = new java.util.Hashtable();
047: labels.put(new Integer(0), new javax.swing.JLabel(""));
048: labels.put(new Integer(60), new javax.swing.JLabel("Sun rise"));
049: labels.put(new Integer(120), new javax.swing.JLabel("Midday"));
050: labels.put(new Integer(180), new javax.swing.JLabel("Sun set"));
051: labels.put(new Integer(240), new javax.swing.JLabel(""));
052: skyTimeSlider.setLabelTable(labels);
053: showSkyCB = new javax.swing.JCheckBox();
054: setLayout(new java.awt.GridBagLayout());
055: java.awt.GridBagConstraints gridBagConstraints1;
056:
057: skyTimeSlider.setPreferredSize(new java.awt.Dimension(250, 44));
058: skyTimeSlider.setPaintLabels(true);
059: skyTimeSlider.setPaintTicks(true);
060: skyTimeSlider.setMajorTickSpacing(60);
061: skyTimeSlider.setMaximum(240);
062: skyTimeSlider.setValue(120);
063: skyTimeSlider
064: .addChangeListener(new javax.swing.event.ChangeListener() {
065: public void stateChanged(
066: javax.swing.event.ChangeEvent evt) {
067: skyTimeSliderStateChanged(evt);
068: }
069: });
070:
071: gridBagConstraints1 = new java.awt.GridBagConstraints();
072: gridBagConstraints1.gridx = 0;
073: gridBagConstraints1.gridy = 0;
074: add(skyTimeSlider, gridBagConstraints1);
075:
076: showSkyCB.setText("Show Sky");
077: showSkyCB
078: .addActionListener(new java.awt.event.ActionListener() {
079: public void actionPerformed(
080: java.awt.event.ActionEvent evt) {
081: showSkyCBActionPerformed(evt);
082: }
083: });
084:
085: gridBagConstraints1 = new java.awt.GridBagConstraints();
086: gridBagConstraints1.gridx = 0;
087: gridBagConstraints1.gridy = 1;
088: add(showSkyCB, gridBagConstraints1);
089:
090: }//GEN-END:initComponents
091:
092: private void showSkyCBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showSkyCBActionPerformed
093: // Add your handling code here:
094: sky.setEnable(showSkyCB.isSelected());
095: }//GEN-LAST:event_showSkyCBActionPerformed
096:
097: private void skyTimeSliderStateChanged(
098: javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_skyTimeSliderStateChanged
099: // Add your handling code here:
100: sky.setTimeOfDay(skyTimeSlider.getValue() / 10f);
101: }//GEN-LAST:event_skyTimeSliderStateChanged
102:
103: /**
104: * Called by J3dSky whenever the time of day changes
105: */
106: public void timeOfDayChange(float time) {
107: skyTimeSlider.setValue((int) (time * 10));
108: }
109:
110: // Variables declaration - do not modify//GEN-BEGIN:variables
111: private javax.swing.JSlider skyTimeSlider;
112: private javax.swing.JCheckBox showSkyCB;
113: // End of variables declaration//GEN-END:variables
114:
115: }
|