home *** CD-ROM | disk | FTP | other *** search
/ The Best of Windows 95.com 1996 September / WIN95_09961.iso / java / mojo1-2e.exe / MOJODISK / DATA.4 / lib / packages / mojo.def < prev    next >
Encoding:
Text File  |  1996-07-01  |  11.6 KB  |  666 lines

  1. DEF_COMPONENTNAME
  2. Animation
  3. DEF_SUPERCLASS
  4. Panel
  5. DEF_SUPERCOMPONENT
  6.  
  7. DEF_PACKAGE
  8. mojo
  9. animation
  10. DEF_ENDLIST
  11. DEF_SUBCOMPONENTLIST
  12. DEF_ENDLIST
  13. DEF_SUBCOMPONENTCLASSLIST
  14. DEF_ENDLIST
  15. DEF_CATEGORY
  16. Animation
  17. DEF_BITMAP
  18.  
  19. DEF_THUMBNAIL_UP
  20. anim2.bmp
  21. DEF_THUMBNAIL_DOWN
  22. 2-anim2.bmp
  23. DEF_VISUAL
  24. DEF_TOOL
  25. DEF_PANEL
  26. DEF_IMPORTS
  27. DEF_ENDLIST
  28. DEF_REQUIRES
  29. FrameChanger
  30. DEF_ENDLIST
  31. DEF_IMPLEMENTS
  32. DEF_ENDLIST
  33. DEF_DECLARATION
  34. // an animation panel component. 
  35.  
  36.    String prefix;         // animation file prefix
  37.    int numberOfFrames;    // number of frames of animation
  38.    int delay;             // delay in milliseconds between frames
  39.    int startFrame;
  40.    int endFrame;
  41.  
  42.    java.awt.Image frame[];
  43.    int currentFrame;
  44.  
  45.    FrameChanger frameChanger;
  46.  
  47. DEF_ENDLIST
  48. DEF_METHOD
  49. public void changeFrames()
  50. // moves to the next frame in the animation seuqence.
  51. {
  52.    currentFrame++;
  53.    if (currentFrame > endFrame)
  54.       currentFrame = startFrame;
  55.    repaint();
  56. }
  57. DEF_ENDLIST
  58. DEF_METHOD
  59. public void paint(Graphics g)
  60. // draw the current frame
  61. {
  62.    if (frame == null) {
  63.       // frames are not loaded to load them
  64.       frame = new java.awt.Image[numberOfFrames + 1];
  65.  
  66.       currentFrame = startFrame;
  67.  
  68.       for (int i = 1; i <= numberOfFrames; i++) {
  69.          frame[i] = applet.getImage(applet.getCodeBase(),
  70.                                     prefix + Integer.toString(i)
  71.                                     + ".gif");
  72.       }
  73.  
  74.       // load the frame changer and start the animation
  75.  
  76.       // use the default FrameChanger constructor
  77.       frameChanger = new FrameChanger();
  78.  
  79.       frameChanger.setAnimationDelay(delay);
  80.       frameChanger.setAnimationComponent(this);
  81.  
  82.       // start the frame changer
  83.       frameChanger.start();
  84.    }
  85.  
  86.    g.drawImage(frame[currentFrame], 0, 0, this);
  87. }
  88. DEF_ENDLIST
  89. DEF_METHOD
  90. public void gotoFrame(int framenumber)
  91. // goes to the specified frame.
  92. // if framenumber is > numberOfFrames, framenumber will be set to max frames
  93. // if framenubmer is < 1, the framenumber is set to 1.
  94. // only perform the operation if the Animation is paused.
  95. {
  96.    if (frameChanger.isPaused() == true) {
  97.       if (framenumber > numberOfFrames)
  98.          currentFrame = numberOfFrames;
  99.       else
  100.          if (framenumber < 1)
  101.             currentFrame = 1;
  102.          else
  103.             currentFrame = framenumber;           
  104.    }
  105. }
  106. DEF_ENDLIST
  107. DEF_METHOD
  108. public void nextFrame()
  109. // goes to the next frame in the animation.
  110. // if framenumber is > numberOfFrames, framenumber will be the max frames
  111. // only perform the operation if the Animation is paused.
  112. {
  113.    if (frameChanger.isPaused() == true) {
  114.       currentFrame--;
  115.       if (currentFrame < 1)
  116.          currentFrame = 1;
  117.       repaint();
  118.    }
  119. }
  120. DEF_ENDLIST
  121. DEF_METHOD
  122. public void prevFrame()
  123. // goes to the previous frame in the animation.
  124. // if framenumber is < 1, framenumber will be set to the first frame 1.
  125. // only perform the operation if the Animation is paused.
  126. {
  127.    if (frameChanger.isPaused() == true) {
  128.       currentFrame++;
  129.       if (currentFrame > numberOfFrames)
  130.          currentFrame = numberOfFrames;
  131.       repaint();
  132.    }
  133. }
  134. DEF_ENDLIST
  135. DEF_METHOD
  136. public void pause()
  137. // pauses the animation.
  138. {
  139.    frameChanger.pause();
  140. }
  141. DEF_ENDLIST
  142. DEF_METHOD
  143. public void play()
  144. // starts an animation.
  145. {
  146.    frameChanger.play();
  147. }
  148. DEF_ENDLIST
  149. DEF_METHOD
  150. public void setDelay(int duration)
  151. {
  152.    delay = duration;
  153. }
  154. DEF_ENDLIST
  155. DEF_METHOD
  156. public int getDelay()
  157. {
  158.    return(delay);
  159. }
  160. DEF_ENDLIST
  161. DEF_METHOD
  162. public void setNumberFrames(int numframes)
  163. {
  164.    numberOfFrames = numframes;
  165. }
  166. DEF_ENDLIST
  167. DEF_METHOD
  168. public int getNumberFrames()
  169. {
  170.    return(numberOfFrames);
  171. }
  172. DEF_ENDLIST
  173. DEF_METHOD
  174. public void setStartFrame(int frame)
  175. {
  176.    startFrame = frame;
  177. }
  178. DEF_ENDLIST
  179. DEF_METHOD
  180. public int getStartFrame()
  181. {
  182.    return(startFrame);
  183. }
  184. DEF_ENDLIST
  185. DEF_METHOD
  186. public void setEndFrame(int frame)
  187. {
  188.    endFrame = frame;
  189. }
  190. DEF_ENDLIST
  191. DEF_METHOD
  192. public int getEndFrame()
  193. {
  194.    return(endFrame);
  195. }
  196. DEF_ENDLIST
  197. DEF_METHOD
  198. public void setPrefix(String fileprefix)
  199. {
  200.    prefix = fileprefix;
  201. }
  202. DEF_ENDLIST
  203. DEF_METHOD
  204. public String getPrefix()
  205. {
  206.    return(prefix);
  207. }
  208. DEF_ENDLIST
  209. DEF_PROPERTY
  210. First Animation Frame
  211. ANIMATION_FILENAME
  212. setPrefix(AVALUE);
  213. AVALUE = getPrefix();
  214.  
  215. DEF_ENDLIST
  216. DEF_PROPERTY
  217. Number of Frames
  218. int
  219. setNumberFrames(AVALUE);
  220. AVALUE = getNumberFrames();
  221. 0
  222. DEF_ENDLIST
  223. DEF_PROPERTY
  224. Start Frame
  225. int
  226. setStartFrame(AVALUE);
  227. AVALUE = getStartFrame();
  228. 0
  229. DEF_ENDLIST
  230. DEF_PROPERTY
  231. End Frame
  232. int
  233. setEndFrame(AVALUE);
  234. AVALUE = getEndFrame();
  235. 0
  236. DEF_ENDLIST
  237. DEF_PROPERTY
  238. Delay (in milliseconds)
  239. int
  240. setDelay(AVALUE);
  241. AVALUE = getDelay();
  242. 0
  243. DEF_ENDLIST
  244. DEF_PROPERTY
  245. Top
  246. int
  247. move(bounds().x, AVALUE);
  248. AVALUE = bounds().y;
  249. 0
  250. DEF_ENDLIST
  251. DEF_PROPERTY
  252. Left
  253. int
  254. move(AVALUE, bounds().y);
  255. AVALUE = bounds().x;
  256. 0
  257. DEF_ENDLIST
  258. DEF_PROPERTY
  259. Height
  260. int
  261. resize(bounds().width, AVALUE);
  262. AVALUE = bounds().height;
  263. 100
  264. DEF_ENDLIST
  265. DEF_PROPERTY
  266. Width
  267. int
  268. resize(AVALUE, bounds().height);
  269. AVALUE = bounds().width;
  270. 100
  271. DEF_ENDLIST
  272. DEF_PROPERTY
  273. ForegroundColor
  274. Color
  275. setForeground(AVALUE);
  276. AVALUE = getForeground();
  277. Color.lightGray
  278. DEF_ENDLIST
  279. DEF_PROPERTY
  280. BackgroundColor
  281. Color
  282. setBackground(AVALUE);
  283. AVALUE = getBackground();
  284. Color.lightGray
  285. DEF_ENDLIST
  286. DEF_PROPERTY
  287. FontName
  288. String
  289. setFont(new Font(AVALUE, getFont().getStyle(), getFont().getSize()));
  290. AVALUE = getFont().getName();
  291. Courier
  292. DEF_ENDLIST
  293. DEF_PROPERTY
  294. FontStyle
  295. int
  296. setFont(new Font(getFont().getName(), AVALUE, getFont().getSize()));
  297. AVALUE = getFont().getStyle();
  298. Font.PLAIN
  299. DEF_ENDLIST
  300. DEF_PROPERTY
  301. FontSize
  302. int
  303. setFont(new Font(getFont().getName(), getFont().getStyle(), AVALUE));
  304. AVALUE = getFont().getSize();
  305. 10
  306. DEF_ENDLIST
  307. DEF_ENDCOMPONENT
  308. DEF_COMPONENTNAME
  309. FrameChanger
  310. DEF_SUPERCLASS
  311. Thread
  312. DEF_SUPERCOMPONENT
  313.  
  314. DEF_PACKAGE
  315. mojo
  316. animation
  317. DEF_ENDLIST
  318. DEF_SUBCOMPONENTLIST
  319. DEF_ENDLIST
  320. DEF_SUBCOMPONENTCLASSLIST
  321. DEF_ENDLIST
  322. DEF_CATEGORY
  323.  
  324. DEF_BITMAP
  325.  
  326. DEF_THUMBNAIL_UP
  327.  
  328. DEF_THUMBNAIL_DOWN
  329.  
  330. DEF_IMPORTS
  331. DEF_ENDLIST
  332. DEF_REQUIRES
  333. DEF_ENDLIST
  334. DEF_IMPLEMENTS
  335. DEF_ENDLIST
  336. DEF_DECLARATION
  337. // Thread Control to change frames in an animation.
  338. // Requires the animation component.
  339.  
  340.    Animation animation;
  341.    int delay;
  342.    boolean paused = false;
  343. DEF_ENDLIST
  344. DEF_METHOD
  345. public void setAnimationComponent(Animation anime)
  346. // sets the frame changers animation component.
  347. {
  348.    animation = anime;
  349. }
  350. DEF_ENDLIST
  351. DEF_METHOD
  352. public void setAnimationDelay(int duration)
  353. // sets the frame changers animation delay in milliseconds.
  354. {
  355.    delay = duration;
  356. }
  357. DEF_ENDLIST
  358. DEF_METHOD
  359. public void pause()
  360. // pauses the animation.
  361. {
  362.    paused = true;
  363. }
  364. DEF_ENDLIST
  365. DEF_METHOD
  366. public void play()
  367. // start the animation running.
  368. {
  369.    paused = false;
  370. }
  371. DEF_ENDLIST
  372. DEF_METHOD
  373. public boolean isPaused()
  374. // returns whether the animation is paused or not.
  375. {
  376.    return(paused);
  377. }
  378. DEF_ENDLIST
  379. DEF_METHOD
  380. public void run()
  381. // change frames on the animation
  382. {
  383.    while (true) {
  384.       if (animation != null) {
  385.          if (paused == false) 
  386.             animation.changeFrames();
  387.          try { Thread.sleep(delay); } catch (InterruptedException e) { break; };
  388.       }
  389.    }
  390. }
  391. DEF_ENDLIST
  392. DEF_ENDCOMPONENT
  393. DEF_COMPONENTNAME
  394. Picture
  395. DEF_SUPERCLASS
  396. Panel
  397. DEF_SUPERCOMPONENT
  398.  
  399. DEF_PACKAGE
  400. mojo
  401. awt
  402. DEF_ENDLIST
  403. DEF_SUBCOMPONENTLIST
  404. DEF_ENDLIST
  405. DEF_SUBCOMPONENTCLASSLIST
  406. DEF_ENDLIST
  407. DEF_CATEGORY
  408. Standard
  409. DEF_BITMAP
  410.  
  411. DEF_THUMBNAIL_UP
  412. pict.bmp
  413. DEF_THUMBNAIL_DOWN
  414. 2-pict.bmp
  415. DEF_VISUAL
  416. DEF_TOOL
  417. DEF_PANEL
  418. DEF_IMPORTS
  419. DEF_ENDLIST
  420. DEF_REQUIRES
  421. DEF_ENDLIST
  422. DEF_IMPLEMENTS
  423. DEF_ENDLIST
  424. DEF_DECLARATION
  425. // A Picture Image class. This produces a generic Image.
  426.  
  427.    java.awt.Image image;
  428.    String filename;
  429. DEF_ENDLIST
  430. DEF_METHOD
  431. public String getFileName()
  432. // returns the filename instance variable
  433. {
  434.   return (filename);
  435. }
  436. DEF_ENDLIST
  437. DEF_METHOD
  438. public void setFileName(String aFileName)
  439. {
  440.   filename = aFileName;
  441.   image = null;
  442. }
  443. DEF_ENDLIST
  444. DEF_METHOD
  445. public void paint(Graphics g)
  446. // draw the current frame
  447. {
  448.   if (image == null) {
  449.      image = applet.getImage(applet.getCodeBase(), filename); 
  450.   }
  451.   g.drawImage(image, 0, 0, this);
  452. }
  453. DEF_ENDLIST
  454. DEF_PROPERTY
  455. Filename
  456. GIF_FILENAME
  457. setFileName(AVALUE);
  458. AVALUE = getFileName();
  459.  
  460. DEF_ENDLIST
  461. DEF_PROPERTY
  462. Top
  463. int
  464. move(bounds().x, AVALUE);
  465. AVALUE = bounds().y;
  466. 0
  467. DEF_ENDLIST
  468. DEF_PROPERTY
  469. Left
  470. int
  471. move(AVALUE, bounds().y);
  472. AVALUE = bounds().x;
  473. 0
  474. DEF_ENDLIST
  475. DEF_PROPERTY
  476. Height
  477. int
  478. resize(bounds().width, AVALUE);
  479. AVALUE = bounds().height;
  480. 100
  481. DEF_ENDLIST
  482. DEF_PROPERTY
  483. Width
  484. int
  485. resize(AVALUE, bounds().height);
  486. AVALUE = bounds().width;
  487. 100
  488. DEF_ENDLIST
  489. DEF_PROPERTY
  490. ForegroundColor
  491. Color
  492. setForeground(AVALUE);
  493. AVALUE = getForeground();
  494. Color.lightGray
  495. DEF_ENDLIST
  496. DEF_PROPERTY
  497. BackgroundColor
  498. Color
  499. setBackground(AVALUE);
  500. AVALUE = getBackground();
  501. Color.lightGray
  502. DEF_ENDLIST
  503. DEF_PROPERTY
  504. FontName
  505. String
  506. setFont(new Font(AVALUE, getFont().getStyle(), getFont().getSize()));
  507. AVALUE = getFont().getName();
  508. Courier
  509. DEF_ENDLIST
  510. DEF_PROPERTY
  511. FontStyle
  512. int
  513. setFont(new Font(getFont().getName(), AVALUE, getFont().getSize()));
  514. AVALUE = getFont().getStyle();
  515. Font.PLAIN
  516. DEF_ENDLIST
  517. DEF_PROPERTY
  518. FontSize
  519. int
  520. setFont(new Font(getFont().getName(), getFont().getStyle(), AVALUE));
  521. AVALUE = getFont().getSize();
  522. 10
  523. DEF_ENDLIST
  524. DEF_ENDCOMPONENT
  525. DEF_COMPONENTNAME
  526. Screen
  527. DEF_SUPERCLASS
  528. Panel
  529. DEF_SUPERCOMPONENT
  530.  
  531. DEF_PACKAGE
  532. mojo
  533. awt
  534. DEF_ENDLIST
  535. DEF_SUBCOMPONENTLIST
  536. DEF_ENDLIST
  537. DEF_SUBCOMPONENTCLASSLIST
  538. DEF_ENDLIST
  539. DEF_CATEGORY
  540.  
  541. DEF_BITMAP
  542.  
  543. DEF_THUMBNAIL_UP
  544.  
  545. DEF_THUMBNAIL_DOWN
  546.  
  547. DEF_VISUAL
  548. DEF_PANEL
  549. DEF_IMPORTS
  550. DEF_ENDLIST
  551. DEF_REQUIRES
  552. DEF_ENDLIST
  553. DEF_IMPLEMENTS
  554. DEF_ENDLIST
  555. DEF_DECLARATION
  556. // A Panel Container class. This produces a generic container.
  557. DEF_ENDLIST
  558. DEF_PROPERTY
  559. Top
  560. int
  561. move(bounds().x, AVALUE);
  562. AVALUE = bounds().y;
  563. 0
  564. DEF_ENDLIST
  565. DEF_PROPERTY
  566. Left
  567. int
  568. move(AVALUE, bounds().y);
  569. AVALUE = bounds().x;
  570. 0
  571. DEF_ENDLIST
  572. DEF_PROPERTY
  573. Height
  574. int
  575. resize(bounds().width, AVALUE);
  576. AVALUE = bounds().height;
  577. 100
  578. DEF_ENDLIST
  579. DEF_PROPERTY
  580. Width
  581. int
  582. resize(AVALUE, bounds().height);
  583. AVALUE = bounds().width;
  584. 100
  585. DEF_ENDLIST
  586. DEF_PROPERTY
  587. ForegroundColor
  588. Color
  589. setForeground(AVALUE);
  590. AVALUE = getForeground();
  591. Color.black
  592. DEF_ENDLIST
  593. DEF_PROPERTY
  594. BackgroundColor
  595. Color
  596. setBackground(AVALUE);
  597. AVALUE = getBackground();
  598. Color.lightGray
  599. DEF_ENDLIST
  600. DEF_PROPERTY
  601. FontName
  602. String
  603. setFont(new Font(AVALUE, getFont().getStyle(), getFont().getSize()));
  604. AVALUE = getFont().getName();
  605. Courier
  606. DEF_ENDLIST
  607. DEF_PROPERTY
  608. FontStyle
  609. int
  610. setFont(new Font(getFont().getName(), AVALUE, getFont().getSize()));
  611. AVALUE = getFont().getStyle();
  612. Font.PLAIN
  613. DEF_ENDLIST
  614. DEF_PROPERTY
  615. FontSize
  616. int
  617. setFont(new Font(getFont().getName(), getFont().getStyle(), AVALUE));
  618. AVALUE = getFont().getSize();
  619. 10
  620. DEF_ENDLIST
  621. DEF_ENDCOMPONENT
  622. DEF_COMPONENTNAME
  623. SoundComponent
  624. DEF_SUPERCLASS
  625. Object
  626. DEF_SUPERCOMPONENT
  627.  
  628. DEF_PACKAGE
  629. mojo
  630. sound
  631. DEF_ENDLIST
  632. DEF_SUBCOMPONENTLIST
  633. DEF_ENDLIST
  634. DEF_SUBCOMPONENTCLASSLIST
  635. DEF_ENDLIST
  636. DEF_CATEGORY
  637.  
  638. DEF_BITMAP
  639.  
  640. DEF_THUMBNAIL_UP
  641.  
  642. DEF_THUMBNAIL_DOWN
  643.  
  644. DEF_IMPORTS
  645. DEF_ENDLIST
  646. DEF_REQUIRES
  647. DEF_ENDLIST
  648. DEF_IMPLEMENTS
  649. DEF_ENDLIST
  650. DEF_DECLARATION
  651. DEF_ENDLIST
  652. DEF_METHOD
  653. public void playSound(String filename)
  654. {
  655.    applet.play(applet.getCodeBase(), filename);
  656. }
  657. DEF_ENDLIST
  658. DEF_TASK
  659. Play Sound
  660. SoundComponent
  661. Multimedia
  662. sndbut.bmp
  663. public void playSound(String filename)
  664. DEF_ENDLIST
  665. DEF_ENDCOMPONENT
  666.