home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Late Night VRML 2.0 with Java CD-ROM
/
code.zip
/
Ch12
/
ui
/
dialogs
/
ImageTextureDialog.java
< prev
next >
Wrap
Text File
|
1997-01-02
|
3KB
|
111 lines
// VRML Generator
// (c) Justin Couch
//
// From Chapter 13: Late Night VRML 2.0 and Java
//
// The Group node dialog. Only needs to get the bounding box size
// and center as well as a DEF name.
package ui.dialogs;
import java.awt.*;
import java.util.*;
import ui.dialogs.VrmlBaseDialog;
import geometry.ImageTexture;
import ui.VrmlTree;
import VrmlScene;
import VrmlTypes;
import exceptions.NoSelectedNodeException;
public class ImageTextureDialog extends VrmlBaseDialog
{
private TextArea URLs;
private Checkbox repeatS, repeatT;
public ImageTextureDialog(Frame parent, VrmlTree tree, VrmlScene data)
{
super(parent, "Edit ImageTexture Node");
vrml_data = data;
screen_data = tree;
content_panel.setLayout(new BorderLayout(5, 5));
// The URL box
Panel p1 = new Panel();
p1.setLayout(new BorderLayout(0, 0));
p1.add("West", new Label("Image URLs:"));
URLs = new TextArea(3, 30);
p1.add("East", URLs);
content_panel.add("North", p1);
// The Texture mapping section
Panel p2 = new Panel();
p2.setLayout(new GridLayout(2, 1));
p2.add(new Label("Texture Wrapping"));
Panel p3 = new Panel();
p3.setLayout(new GridLayout(1, 2));
repeatS = new Checkbox(" S", null, true);
repeatT = new Checkbox(" T", null, true);
p3.add(repeatS);
p3.add(repeatT);
p2.add(p3);
content_panel.add("South", p2);
pack();
}
// read all the information back out of the panel and pass it
// to the appropriate place.
public boolean applyInformation()
{
int i;
String str;
StringTokenizer strtok;
String[] url_strings;
ImageTexture it;
// are we creating a default node? This test for a yes
if(!repeatS.getState() || !repeatT.getState())
it = new ImageTexture(browser, repeatS.getState(), repeatT.getState());
else
it = new ImageTexture(browser);
str = name.getText();
if(str.equals(""))
it.name = null;
else
it.name = new String(str);
// now put in the URLs The problem is that we need to break up
// a single line of text into multiple strings. Do this with a
// stringTokeniser; The delimiters are: comma, space, CR, LF, tab
strtok = new StringTokenizer(URLs.getText());
url_strings = new String[strtok.countTokens()];
for(i = 0; i < strtok.countTokens(); i++)
url_strings[i] = new String(strtok.nextToken());
it.set_URL(url_strings);
try
{
vrml_data.addNode(VrmlTypes.ImageTexture, it);
}
catch (NoSelectedNodeException e)
{
System.out.println("No node selected");
}
return false;
}
}