home *** CD-ROM | disk | FTP | other *** search
Wrap
import java.awt.Button; import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.FileDialog; import java.awt.Font; import java.awt.Frame; import java.awt.Label; import java.awt.LayoutManager; import java.awt.Menu; import java.awt.MenuBar; import java.awt.MenuItem; import java.awt.Point; import java.awt.Rectangle; import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.WindowEvent; import java.beans.PropertyVetoException; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FilterInputStream; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import symantec.itools.awt.WrappingLabel; import symantec.itools.multimedia.ImageViewer; import symantec.itools.multimedia.SlideShow; import symantec.itools.net.RelativeURL; public class AmazingTour extends Frame { int dayCount; String fileName; Rectangle slideShowBounds; boolean fComponentsAdjusted; FileDialog openFileDialog1; WrappingLabel wrappingLabelStart; WrappingLabel wrappingLabelTop; WrappingLabel wrappingLabelPeople; ImageViewer imageViewerLogo; SlideShow slideShowItinerary; Label labelDay; Button buttonNext; Button buttonPrevious; WrappingLabel wrappingLabelDesc; AmazingTour$SymAction glAction; MenuBar mainMenuBar; Menu menu1; MenuItem miOpen; MenuItem miExit; Menu menu3; MenuItem miAbout; void miAbout_Action(ActionEvent event) { (new AboutDialog(this, true)).show(); } void miExit_Action(ActionEvent event) { (new QuitDialog(this, true)).show(); } void miOpen_Action(ActionEvent event) { this.openFileDialog1.show(); String tempFileName = this.openFileDialog1.getDirectory() + this.openFileDialog1.getFile(); if ((this.fileName != null || tempFileName.endsWith(".dat")) && tempFileName.endsWith(".dat")) { if (this.fileName == null) { this.wrappingLabelStart.hide(); } this.fileName = tempFileName; if (this.slideShowItinerary != null) { ((Container)this).remove(this.slideShowItinerary); } this.dayCount = 1; if (this.slideShowItinerary != null) { this.slideShowItinerary.removeActionListener(this.glAction); } this.slideShowItinerary = new SlideShow(); this.slideShowItinerary.addActionListener(this.glAction); this.slideShowItinerary.reshape(((Container)this).insets().left + this.slideShowBounds.x, ((Container)this).insets().top + this.slideShowBounds.y, this.slideShowBounds.width, this.slideShowBounds.height); ((Container)this).add(this.slideShowItinerary); this.getEntries(this.openFileDialog1.getDirectory(), this.fileName); this.buttonNext.show(); this.buttonPrevious.show(); try { this.wrappingLabelTop.setText("Custom Itinerary for"); } catch (PropertyVetoException var4) { } this.labelDay.setText("Day " + this.dayCount); try { this.wrappingLabelDesc.setText(this.slideShowItinerary.getDescription(this.slideShowItinerary.getCurrentImageIndex())); } catch (PropertyVetoException var3) { } this.buttonPrevious.disable(); if (this.slideShowItinerary.isAtLastImage()) { this.buttonNext.disable(); } else { this.buttonNext.enable(); } } } void Frame1_WindowClosing(WindowEvent event) { ((Component)this).hide(); ((Frame)this).dispose(); System.exit(0); } public AmazingTour() { this.dayCount = 1; this.fComponentsAdjusted = false; ((Container)this).setLayout((LayoutManager)null); ((Component)this).setVisible(false); ((Component)this).setSize(600, 530); ((Component)this).setFont(new Font("Dialog", 0, 12)); ((Component)this).setForeground(new Color(0)); ((Component)this).setBackground(new Color(16777215)); this.openFileDialog1 = new FileDialog(this); this.openFileDialog1.setMode(0); this.openFileDialog1.setTitle("Open"); this.wrappingLabelStart = new WrappingLabel(); try { this.wrappingLabelStart.setText("To start, choose Open from the File menu and open your data file. Your .dat file and the graphics files must be in the same directory."); } catch (PropertyVetoException var8) { } this.wrappingLabelStart.setBounds(5, 16, 247, 179); this.wrappingLabelStart.setFont(new Font("Dialog", 1, 16)); ((Container)this).add(this.wrappingLabelStart); this.wrappingLabelTop = new WrappingLabel(); try { this.wrappingLabelTop.setText("Custom itinerary for"); } catch (PropertyVetoException var7) { } try { this.wrappingLabelTop.setAlignStyle(1); } catch (PropertyVetoException var6) { } this.wrappingLabelTop.setBounds(7, 18, 244, 52); this.wrappingLabelTop.setFont(new Font("Dialog", 1, 16)); ((Container)this).add(this.wrappingLabelTop); this.wrappingLabelPeople = new WrappingLabel(); try { this.wrappingLabelPeople.setAlignStyle(1); } catch (PropertyVetoException var5) { } this.wrappingLabelPeople.setBounds(7, 75, 244, 109); this.wrappingLabelPeople.setFont(new Font("Dialog", 1, 24)); ((Container)this).add(this.wrappingLabelPeople); this.imageViewerLogo = new ImageViewer(); try { this.imageViewerLogo.setImageURL(RelativeURL.getURL("Images/Logo.gif")); } catch (MalformedURLException var3) { } catch (PropertyVetoException var4) { } this.imageViewerLogo.setBounds(268, 2, 311, 203); ((Container)this).add(this.imageViewerLogo); this.slideShowItinerary = new SlideShow(); this.slideShowItinerary.setBounds(254, 232, 340, 235); ((Container)this).add(this.slideShowItinerary); this.labelDay = new Label("", 1); this.labelDay.setBounds(65, 199, 108, 32); this.labelDay.setFont(new Font("Dialog", 2, 16)); ((Container)this).add(this.labelDay); this.buttonNext = new Button(); this.buttonNext.setActionCommand("button"); this.buttonNext.setLabel("Next"); this.buttonNext.setVisible(false); this.buttonNext.setBounds(431, 470, 80, 31); ((Container)this).add(this.buttonNext); this.buttonPrevious = new Button(); this.buttonPrevious.setActionCommand("button"); this.buttonPrevious.setLabel("Previous"); this.buttonPrevious.setVisible(false); this.buttonPrevious.setBounds(341, 470, 80, 31); ((Container)this).add(this.buttonPrevious); this.wrappingLabelDesc = new WrappingLabel(); this.wrappingLabelDesc.setBounds(8, 236, 240, 265); this.wrappingLabelDesc.setFont(new Font("Dialog", 0, 14)); ((Container)this).add(this.wrappingLabelDesc); ((Frame)this).setTitle("Amazing Adventures Travel - Custom Itinerary Application"); this.slideShowBounds = this.slideShowItinerary.bounds(); this.mainMenuBar = new MenuBar(); this.menu1 = new Menu("File"); this.miOpen = new MenuItem("Open..."); this.menu1.add(this.miOpen); this.menu1.addSeparator(); this.miExit = new MenuItem("Exit"); this.menu1.add(this.miExit); this.mainMenuBar.add(this.menu1); this.menu3 = new Menu("Help"); this.mainMenuBar.setHelpMenu(this.menu3); this.miAbout = new MenuItem("About.."); this.menu3.add(this.miAbout); this.mainMenuBar.add(this.menu3); ((Frame)this).setMenuBar(this.mainMenuBar); AmazingTour$SymWindow aSymWindow = new AmazingTour$SymWindow(this); ((Window)this).addWindowListener(aSymWindow); AmazingTour$SymAction lSymAction = new AmazingTour$SymAction(this); this.miOpen.addActionListener(lSymAction); this.miAbout.addActionListener(lSymAction); this.miExit.addActionListener(lSymAction); this.buttonPrevious.addActionListener(lSymAction); this.buttonNext.addActionListener(lSymAction); this.slideShowItinerary.addActionListener(lSymAction); this.glAction = lSymAction; } public AmazingTour(String title) { this(); ((Frame)this).setTitle(title); } public synchronized void show() { ((Component)this).move(50, 50); super.show(); } public static void main(String[] args) { (new AmazingTour()).show(); } public void addNotify() { super.addNotify(); if (!this.fComponentsAdjusted) { ((Component)this).setSize(((Container)this).insets().left + ((Container)this).insets().right + ((Component)this).getSize().width, ((Container)this).insets().top + ((Container)this).insets().bottom + ((Component)this).getSize().height); Component[] components = ((Container)this).getComponents(); for(int i = 0; i < components.length; ++i) { Point p = components[i].getLocation(); p.translate(((Container)this).insets().left, ((Container)this).insets().top); components[i].setLocation(p); } this.fComponentsAdjusted = true; } } private void getEntries(String dir, String filename) { try { DataInputStream in = new DataInputStream(new FileInputStream(filename)); try { this.wrappingLabelPeople.setText(in.readLine()); } catch (PropertyVetoException var8) { } int numEntries = Integer.parseInt(in.readLine()); dir = "file:/" + dir.substring(0, dir.lastIndexOf(92)); for(int i = 0; i < numEntries; ++i) { String s1 = dir + "/" + in.readLine(); String s2 = in.readLine(); this.slideShowItinerary.addImageAndDescription(new URL(s1), s2); } ((FilterInputStream)in).close(); ((Container)this).invalidate(); ((Container)this).validate(); } catch (FileNotFoundException var9) { System.err.println("Can't open " + filename); } catch (IOException var10) { System.err.println("Error reading " + filename); } } void buttonPrevious_Action(ActionEvent event) { this.slideShowItinerary.previousImage(); this.labelDay.setText("Day " + --this.dayCount); } void buttonNext_Action(ActionEvent event) { this.slideShowItinerary.nextImage(); this.labelDay.setText("Day " + ++this.dayCount); } void slideShowItinerary_SlideChanged(ActionEvent event) { this.buttonNext.setEnabled(!this.slideShowItinerary.isAtLastImage()); this.buttonPrevious.setEnabled(!this.slideShowItinerary.isAtFirstImage()); try { this.wrappingLabelDesc.setText(this.slideShowItinerary.getDescription(this.slideShowItinerary.getCurrentImageIndex())); } catch (PropertyVetoException var2) { } } }