Christian Heimke commited on 2011-07-15 09:23:24
Showing 9 changed files, with 336 additions and 142 deletions.
... | ... |
@@ -1,8 +1,13 @@ |
1 | 1 |
BlinkenLightsInteractiveMovieProgram |
2 |
-Copyright (C) 2004-2006: Stefan Schuermans <1stein@schuermans.info> |
|
2 |
+Copyright (C) 2004-2008: Stefan Schuermans <stefan@schuermans.info> |
|
3 | 3 |
Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
4 | 4 |
a blinkenarea.org project |
5 |
-powered by eventphone.de |
|
5 |
+ |
|
6 |
+version 1.3.2 date 2008-02-23 |
|
7 |
+----------------------------- |
|
8 |
+ - added menu items for known formats |
|
9 |
+ - thanks to Christian Heimke for the idea and the first implementation |
|
10 |
+ - added buttons to initialize color buttons to gray and to color |
|
6 | 11 |
|
7 | 12 |
version 1.3.1 date 2006-10-17 |
8 | 13 |
----------------------------- |
... | ... |
@@ -1,9 +1,8 @@ |
1 | 1 |
# BlinkenLightsInteractiveMovieProgram |
2 |
-# version 1.3.1 date 2006-10-17 |
|
3 |
-# Copyright (C) 2004-2006: Stefan Schuermans <1stein@schuermans.info> |
|
2 |
+# version 1.3.2 date 2008-02-23 |
|
3 |
+# Copyright (C) 2004-2008: Stefan Schuermans <stefan@schuermans.info> |
|
4 | 4 |
# Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
5 | 5 |
# a blinkenarea.org project |
6 |
-# powered by eventphone.de |
|
7 | 6 |
|
8 | 7 |
BLINKEN_LIB=../BlinkenLibJava/BlinkenLib.jar |
9 | 8 |
|
... | ... |
@@ -1,9 +1,8 @@ |
1 | 1 |
/* BlinkenLightsInteractiveMovieProgram |
2 |
- * version 1.3.1 date 2006-10-17 |
|
3 |
- * Copyright (C) 2004-2006: Stefan Schuermans <1stein@schuermans.info> |
|
2 |
+ * version 1.3.2 date 2008-02-23 |
|
3 |
+ * Copyright (C) 2004-2008: Stefan Schuermans <stefan@schuermans.info> |
|
4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
5 | 5 |
* a blinkenarea.org project |
6 |
- * powered by eventphone.de |
|
7 | 6 |
*/ |
8 | 7 |
|
9 | 8 |
package org.blinkenarea.Blimp; |
... | ... |
@@ -32,6 +31,30 @@ public class Blimp extends JApplet |
32 | 31 |
static final int defHeight = 8, defWidth = 8, defChannels = 1, defMaxval = 127, defDuration = 100; |
33 | 32 |
static final int ZoomAspectResolution = 30; |
34 | 33 |
|
34 |
+ //known formats |
|
35 |
+ static final String[] knownFormats = |
|
36 |
+ { |
|
37 |
+ "Blinkenlights (18x8-1/2)", |
|
38 |
+ "Blinkenlights Arcade (26x20-1/16)", |
|
39 |
+ "Blinkenlights reloaded (18x8-1/16)", |
|
40 |
+ "bluebox (98x7-1/128)", |
|
41 |
+ "PixelCurtain (18x8-3/256)", |
|
42 |
+ "TROIA big walls (104x32-1/128)", |
|
43 |
+ "TROIA ceiling (104x80-1/128)", |
|
44 |
+ "TROIA small walls (80x32-1/128)", |
|
45 |
+ }; |
|
46 |
+ |
|
47 |
+ //known sizes |
|
48 |
+ static final String[] knownSizes = |
|
49 |
+ { |
|
50 |
+ "Blinkenlights (18x8)", |
|
51 |
+ "Blinkenlights Arcade (26x20)", |
|
52 |
+ "bluebox (98x7)", |
|
53 |
+ "TROIA big walls (104x32)", |
|
54 |
+ "TROIA ceiling (104x80)", |
|
55 |
+ "TROIA small walls (80x32)", |
|
56 |
+ }; |
|
57 |
+ |
|
35 | 58 |
//configuration variables |
36 | 59 |
boolean isFullApp = false; //if running as full application |
37 | 60 |
String initialFile = null; |
... | ... |
@@ -43,7 +66,9 @@ public class Blimp extends JApplet |
43 | 66 |
JMenu menuFile, menuInfo, menuEdit, menuFrameSel, menuPlay, menuHelp; //menus |
44 | 67 |
JMenuItem menuFileNew, menuFileLoad, menuFileSave, menuFileSaveAs, menuFileQuit; |
45 | 68 |
JMenuItem menuInfoShow, menuInfoAdd, menuInfoDelete; |
46 |
- JMenuItem menuEditResize, menuEditScale; |
|
69 |
+ JMenu menuEditResize, menuEditScale; |
|
70 |
+ JMenuItem menuEditResizeUser, menuEditScaleUser; |
|
71 |
+ JMenuItem menuEditResizeKnown[], menuEditScaleKnown[]; |
|
47 | 72 |
JMenuItem menuEditInsertFrame, menuEditDuplicateFrame, menuEditDeleteFrame; |
48 | 73 |
JMenuItem menuFrameSelNone, menuFrameSelSingle, menuFrameSelStart, menuFrameSelEnd; |
49 | 74 |
JMenuItem menuFrameSelCopy, menuFrameSelMove, menuFrameSelReverse, menuFrameSelDelete; |
... | ... |
@@ -73,7 +98,8 @@ public class Blimp extends JApplet |
73 | 98 |
JButton buttonActionsRollLeft, buttonActionsRollRight, buttonActionsRollUp, buttonActionsRollDown; |
74 | 99 |
JButton buttonActionsUndo, buttonActionsRedo; |
75 | 100 |
JButton buttonEditInsertFrame, buttonEditDuplicateFrame, buttonEditDeleteFrame; |
76 |
- JPanel panelColorsChoose, panelColorsSettings, panelColorsColor, panelColorsAlpha; |
|
101 |
+ JButton buttonColorsPredefGray, buttonColorsPredefColor; |
|
102 |
+ JPanel panelColorsChoose, panelColorsSettings, panelColorsPredef, panelColorsColor, panelColorsAlpha; |
|
77 | 103 |
JToggleButton buttonsColor[]; |
78 | 104 |
ButtonGroup groupColor; |
79 | 105 |
JLabel labelColorsColor, labelColorsAlpha; |
... | ... |
@@ -175,7 +201,7 @@ public class Blimp extends JApplet |
175 | 201 |
labelStatus.setText( "new movie..." ); |
176 | 202 |
curFile = null; |
177 | 203 |
curMovie = new BlinkenMovie( defHeight, defWidth, defChannels, defMaxval ); |
178 |
- curMovie.insertInfo( 0, "creator", "Blimp (version 1.3.1 date 2006-10-17)" ); |
|
204 |
+ curMovie.insertInfo( 0, "creator", "Blimp (version 1.3.2 date 2008-02-23)" ); |
|
179 | 205 |
curMovie.insertFrame( 0, new BlinkenFrame( defHeight, defWidth, defChannels, defMaxval, defDuration ) ); |
180 | 206 |
curMovieChanged = false; |
181 | 207 |
|
... | ... |
@@ -398,115 +424,133 @@ public class Blimp extends JApplet |
398 | 424 |
} |
399 | 425 |
} |
400 | 426 |
|
401 |
- //"Edit Resize Movie..." was chosen from menu |
|
402 |
- private void actionEditResize( ) |
|
427 |
+ //get format or size from bracket in string |
|
428 |
+ private String getFormatOrSize( String str ) |
|
403 | 429 |
{ |
404 |
- Pattern sizePattern; |
|
405 |
- String curSize; |
|
406 |
- Object size; |
|
407 |
- Matcher sizeMatcher; |
|
430 |
+ Pattern pattern; |
|
431 |
+ Matcher matcher; |
|
408 | 432 |
|
409 |
- //initialize size pattern |
|
410 |
- sizePattern = Pattern.compile( "^([0-9]+)x([0-9]+)-([0-9]+)/([0-9]+)$" ); |
|
433 |
+ pattern = Pattern.compile( "^.*\\(([^()]*)\\)$" ); |
|
434 |
+ if( (matcher = pattern.matcher( str )).find( ) ) |
|
435 |
+ return matcher.group( 1 ); |
|
436 |
+ else |
|
437 |
+ return ""; |
|
438 |
+ } |
|
411 | 439 |
|
412 |
- //get string with current movie size |
|
413 |
- curSize = curMovie.getWidth( ) + "x" + |
|
440 |
+ //resize to format |
|
441 |
+ private boolean actionEditResizeToFormat( String format ) |
|
442 |
+ { |
|
443 |
+ Pattern formatPattern; |
|
444 |
+ Matcher formatMatcher; |
|
445 |
+ |
|
446 |
+ //initialize format pattern |
|
447 |
+ formatPattern = Pattern.compile( "^([0-9]+)x([0-9]+)-([0-9]+)/([0-9]+)$" ); |
|
448 |
+ |
|
449 |
+ //check format |
|
450 |
+ if( ! (formatMatcher = formatPattern.matcher( format )).find( ) ) //abort and return error if format not valid |
|
451 |
+ return false; |
|
452 |
+ |
|
453 |
+ //resize movie |
|
454 |
+ curMovie.resize( Integer.parseInt( formatMatcher.group( 2 ) ), |
|
455 |
+ Integer.parseInt( formatMatcher.group( 1 ) ), |
|
456 |
+ Integer.parseInt( formatMatcher.group( 3 ) ), |
|
457 |
+ Integer.parseInt( formatMatcher.group( 4 ) ) - 1 ); |
|
458 |
+ curMovieChanged = true; |
|
459 |
+ |
|
460 |
+ //update controls |
|
461 |
+ updateFrames( scrollFrames.getValue( ) ); |
|
462 |
+ |
|
463 |
+ //update status |
|
464 |
+ labelStatus.setText( "movie resized successfully to " + format + "..." ); |
|
465 |
+ |
|
466 |
+ return true; |
|
467 |
+ } |
|
468 |
+ |
|
469 |
+ //"Edit Resize Movie user defined format..." was chosen from menu |
|
470 |
+ private void actionEditResizeUser( ) |
|
471 |
+ { |
|
472 |
+ String curFormat; |
|
473 |
+ Object format; |
|
474 |
+ |
|
475 |
+ //get string with current movie format |
|
476 |
+ curFormat = curMovie.getWidth( ) + "x" + |
|
414 | 477 |
curMovie.getHeight( ) + "-" + |
415 | 478 |
curMovie.getChannels( ) + "/" + |
416 | 479 |
(curMovie.getMaxval( ) + 1); |
417 | 480 |
|
418 | 481 |
//ask until cancel or answer is valid |
419 |
- size = curSize; |
|
482 |
+ format = curFormat; |
|
420 | 483 |
do |
421 | 484 |
{ |
422 |
- //ask for new size |
|
423 |
- size = JOptionPane.showInputDialog( dialogParent, |
|
424 |
- "Current movie size is: " + curSize + "\n\n" + |
|
425 |
- "The format is: <width>x<height>-<channels>/<colors>\n" + |
|
426 |
- " 18x8-1/2 (Blinkenlights)\n" + |
|
427 |
- " 18x8-1/16 (Blinkenlights Reloaded)\n" + |
|
428 |
- " 26x20-1/16 (Blinkenlights Arcade)\n" + |
|
429 |
- " 104x32-1/128 (TROIA big walls)\n" + |
|
430 |
- " 80x32-1/128 (TROIA small walls)\n" + |
|
431 |
- " 104x80-1/128 (TROIA floor + ceiling)\n" + |
|
432 |
- " 98x7-1/128 (bluebox)\n\n" + |
|
433 |
- "Please enter the new movie size:", |
|
485 |
+ //ask for new format |
|
486 |
+ format = JOptionPane.showInputDialog( dialogParent, |
|
487 |
+ "Current movie format is: " + curFormat + "\n\n" + |
|
488 |
+ "The format is: <width>x<height>-<channels>/<colors>\n\n" + |
|
489 |
+ "Please enter the new movie format:", |
|
434 | 490 |
"Blimp - Resize Movie...", |
435 | 491 |
JOptionPane.QUESTION_MESSAGE, |
436 |
- null, null, size ); |
|
492 |
+ null, null, format ); |
|
437 | 493 |
//dialog was cancelled |
438 |
- if( size == null ) |
|
494 |
+ if( format == null ) |
|
439 | 495 |
return; |
440 | 496 |
} |
441 |
- while( ! (sizeMatcher = sizePattern.matcher( size.toString( ) )).find( ) ); //repeat question if answer not valid |
|
497 |
+ while( ! actionEditResizeToFormat( format.toString( ) ) ); //repeat question if answer not valid |
|
498 |
+ } |
|
442 | 499 |
|
443 |
- //resize movie |
|
444 |
- curMovie.resize( Integer.parseInt( sizeMatcher.group( 2 ) ), |
|
445 |
- Integer.parseInt( sizeMatcher.group( 1 ) ), |
|
446 |
- Integer.parseInt( sizeMatcher.group( 3 ) ), |
|
447 |
- Integer.parseInt( sizeMatcher.group( 4 ) ) - 1 ); |
|
500 |
+ // scale to size |
|
501 |
+ private boolean actionEditScaleToSize( String size ) |
|
502 |
+ { |
|
503 |
+ Pattern sizePattern; |
|
504 |
+ Matcher sizeMatcher; |
|
505 |
+ |
|
506 |
+ //initialize size pattern |
|
507 |
+ sizePattern = Pattern.compile( "^([0-9]+)x([0-9]+)$" ); |
|
508 |
+ |
|
509 |
+ //ask until cancel or answer is valid |
|
510 |
+ if( ! (sizeMatcher = sizePattern.matcher( size.toString( ) )).find( ) ) //abort and return error if size not valid |
|
511 |
+ return false; |
|
512 |
+ |
|
513 |
+ //scale movie |
|
514 |
+ curMovie.scale( Integer.parseInt( sizeMatcher.group( 2 ) ), |
|
515 |
+ Integer.parseInt( sizeMatcher.group( 1 ) ) ); |
|
448 | 516 |
curMovieChanged = true; |
449 | 517 |
|
450 | 518 |
//update controls |
451 | 519 |
updateFrames( scrollFrames.getValue( ) ); |
452 | 520 |
|
453 | 521 |
//update status |
454 |
- labelStatus.setText( "movie resized successfully to " + size.toString( ) + "..." ); |
|
522 |
+ labelStatus.setText( "movie scaled successfully to " + size + "..." ); |
|
523 |
+ |
|
524 |
+ return true; |
|
455 | 525 |
} |
456 | 526 |
|
457 |
- //"Edit Scale Movie..." was chosen from menu |
|
458 |
- private void actionEditScale( ) |
|
527 |
+ //"Edit Scale Movie user defined size..." was chosen from menu |
|
528 |
+ private void actionEditScaleUser( ) |
|
459 | 529 |
{ |
460 |
- Pattern dimPattern; |
|
461 |
- String curDim, curSize; |
|
462 |
- Object dim; |
|
463 |
- Matcher dimMatcher; |
|
464 |
- |
|
465 |
- //initialize dimension pattern |
|
466 |
- dimPattern = Pattern.compile( "^([0-9]+)x([0-9]+)$" ); |
|
530 |
+ String curSize; |
|
531 |
+ Object size; |
|
467 | 532 |
|
468 | 533 |
//get string with current movie size |
469 |
- curDim = curMovie.getWidth( ) + "x" + |
|
470 |
- curMovie.getHeight( ); |
|
471 | 534 |
curSize = curMovie.getWidth( ) + "x" + |
472 |
- curMovie.getHeight( ) + "-" + |
|
473 |
- curMovie.getChannels( ) + "/" + |
|
474 |
- (curMovie.getMaxval( ) + 1); |
|
535 |
+ curMovie.getHeight( ); |
|
475 | 536 |
|
476 | 537 |
//ask until cancel or answer is valid |
477 |
- dim = curDim; |
|
538 |
+ size = curSize; |
|
478 | 539 |
do |
479 | 540 |
{ |
480 | 541 |
//ask for new size |
481 |
- dim = JOptionPane.showInputDialog( dialogParent, |
|
482 |
- "Current movie dimension is: " + curDim + " (" + curSize + ")\n\n" + |
|
483 |
- "The format is: <width>x<height>\n" + |
|
484 |
- " 18x8 (Blinkenlights, Blinkenlights Reloaded)\n" + |
|
485 |
- " 26x20 (Blinkenlights Arcade)\n" + |
|
486 |
- " 104x32 (TROIA big walls)\n" + |
|
487 |
- " 80x32 (TROIA small walls)\n" + |
|
488 |
- " 104x80 (TROIA floor + ceiling)\n" + |
|
489 |
- " 98x7 (bluebox)\n\n" + |
|
542 |
+ size = JOptionPane.showInputDialog( dialogParent, |
|
543 |
+ "Current movie dimension is: " + curSize + "\n\n" + |
|
544 |
+ "The format is: <width>x<height>\n\n" + |
|
490 | 545 |
"Please enter the new movie dimension:", |
491 | 546 |
"Blimp - Scale Movie...", |
492 | 547 |
JOptionPane.QUESTION_MESSAGE, |
493 |
- null, null, dim ); |
|
548 |
+ null, null, size ); |
|
494 | 549 |
//dialog was cancelled |
495 |
- if( dim == null ) |
|
550 |
+ if( size == null ) |
|
496 | 551 |
return; |
497 | 552 |
} |
498 |
- while( ! (dimMatcher = dimPattern.matcher( dim.toString( ) )).find( ) ); //repeat question if answer not valid |
|
499 |
- |
|
500 |
- //scale movie |
|
501 |
- curMovie.scale( Integer.parseInt( dimMatcher.group( 2 ) ), |
|
502 |
- Integer.parseInt( dimMatcher.group( 1 ) ) ); |
|
503 |
- curMovieChanged = true; |
|
504 |
- |
|
505 |
- //update controls |
|
506 |
- updateFrames( scrollFrames.getValue( ) ); |
|
507 |
- |
|
508 |
- //update status |
|
509 |
- labelStatus.setText( "movie scaled successfully to " + dim.toString( ) + "..." ); |
|
553 |
+ while( ! actionEditScaleToSize( size.toString( ) ) ); //repeat question if answer not valid |
|
510 | 554 |
} |
511 | 555 |
|
512 | 556 |
//"Edit Insert Frame" was chosen from menu / Insert Frame button was pressed |
... | ... |
@@ -986,11 +1030,10 @@ public class Blimp extends JApplet |
986 | 1030 |
{ |
987 | 1031 |
JOptionPane.showMessageDialog( dialogParent, |
988 | 1032 |
"BlinkenLightsInteractiveMovieProgram\n" + |
989 |
- "version 1.3.1 date 2006-10-17\n" + |
|
990 |
- "Copyright (C) 2004-2006: Stefan Schuermans <1stein@schuermans.info>\n" + |
|
1033 |
+ "version 1.3.2 date 2008-02-23\n" + |
|
1034 |
+ "Copyright (C) 2004-2008: Stefan Schuermans <stefan@schuermans.info>\n" + |
|
991 | 1035 |
"Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html\n" + |
992 |
- "a blinkenarea.org project\n" + |
|
993 |
- "powered by eventphone.de", |
|
1036 |
+ "a blinkenarea.org project", |
|
994 | 1037 |
"Blimp - About...", |
995 | 1038 |
JOptionPane.INFORMATION_MESSAGE ); |
996 | 1039 |
} |
... | ... |
@@ -1307,11 +1350,10 @@ public class Blimp extends JApplet |
1307 | 1350 |
showDuration( ); |
1308 | 1351 |
} |
1309 | 1352 |
|
1310 |
- //generate a color icon from a color |
|
1311 |
- private void iconFromColor( ImageIcon icon, Color color ) |
|
1353 |
+ //generate a gray gradient icon |
|
1354 |
+ private void iconGradientGray( ImageIcon icon ) |
|
1312 | 1355 |
{ |
1313 |
- int height, width, y, x; |
|
1314 |
- boolean yy, xx; |
|
1356 |
+ int height, width, val, x; |
|
1315 | 1357 |
Graphics graphics; |
1316 | 1358 |
|
1317 | 1359 |
//get size |
... | ... |
@@ -1321,22 +1363,59 @@ public class Blimp extends JApplet |
1321 | 1363 |
//get graphics context of icon's image |
1322 | 1364 |
graphics = icon.getImage( ).getGraphics( ); |
1323 | 1365 |
|
1324 |
- //draw background |
|
1325 |
- graphics.setColor( new Color( color.getRed( ), color.getGreen( ), color.getBlue( ) ) ); |
|
1326 |
- graphics.fillRect( 0, 0, width / 2, height ); |
|
1327 |
- for( y = 0, yy = false; y < height; y += height / 4, yy = ! yy ) |
|
1328 |
- { |
|
1329 |
- for( x = width / 2, xx = yy; x < width; x += width / 6, xx = ! xx ) |
|
1366 |
+ //draw gradient to icon |
|
1367 |
+ for( x = 0; x < width; x++ ) { |
|
1368 |
+ val = x * 255 / (width - 1); |
|
1369 |
+ graphics.setColor( new Color( val, val, val ) ); |
|
1370 |
+ graphics.drawLine( x, 0, x, height ); |
|
1371 |
+ } |
|
1372 |
+ } |
|
1373 |
+ |
|
1374 |
+ //generate a color gradient icon |
|
1375 |
+ private void iconGradientColor( ImageIcon icon ) |
|
1330 | 1376 |
{ |
1331 |
- if( xx ) |
|
1332 |
- graphics.setColor( Color.white ); |
|
1333 |
- else |
|
1334 |
- graphics.setColor( Color.black ); |
|
1335 |
- graphics.fillRect( x, y, width / 6, height / 4 ); |
|
1377 |
+ int height, width, val, step, x; |
|
1378 |
+ Graphics graphics; |
|
1379 |
+ |
|
1380 |
+ //get size |
|
1381 |
+ height = icon.getIconHeight( ); |
|
1382 |
+ width = icon.getIconWidth( ); |
|
1383 |
+ |
|
1384 |
+ //get graphics context of icon's image |
|
1385 |
+ graphics = icon.getImage( ).getGraphics( ); |
|
1386 |
+ |
|
1387 |
+ //draw gradient to icon |
|
1388 |
+ for( x = 0; x < width; x++ ) { |
|
1389 |
+ val = x * 6 * 255 / (width - 1); |
|
1390 |
+ step = val / 255; |
|
1391 |
+ val %= 255; |
|
1392 |
+ switch( step ) { |
|
1393 |
+ case 0: graphics.setColor( new Color( 255, val, 0 ) ); break; |
|
1394 |
+ case 1: graphics.setColor( new Color( 255 - val, 255, 0 ) ); break; |
|
1395 |
+ case 2: graphics.setColor( new Color( 0, 255, val ) ); break; |
|
1396 |
+ case 3: graphics.setColor( new Color( 0, 255 - val, 255 ) ); break; |
|
1397 |
+ case 4: graphics.setColor( new Color( val, 0, 255 ) ); break; |
|
1398 |
+ case 5: graphics.setColor( new Color( 255, 0, 255 - val ) ); break; |
|
1336 | 1399 |
} |
1400 |
+ graphics.drawLine( x, 0, x, height ); |
|
1337 | 1401 |
} |
1402 |
+ } |
|
1403 |
+ |
|
1404 |
+ //generate a color icon from a color |
|
1405 |
+ private void iconFromColor( ImageIcon icon, Color color ) |
|
1406 |
+ { |
|
1407 |
+ int height, width, y, x; |
|
1408 |
+ boolean yy, xx; |
|
1409 |
+ Graphics graphics; |
|
1410 |
+ |
|
1411 |
+ //get size |
|
1412 |
+ height = icon.getIconHeight( ); |
|
1413 |
+ width = icon.getIconWidth( ); |
|
1338 | 1414 |
|
1339 |
- //draw foreground in specified color |
|
1415 |
+ //get graphics context of icon's image |
|
1416 |
+ graphics = icon.getImage( ).getGraphics( ); |
|
1417 |
+ |
|
1418 |
+ //fill icon in specified color |
|
1340 | 1419 |
graphics.setColor( color ); |
1341 | 1420 |
graphics.fillRect( 0, 0, width, height ); |
1342 | 1421 |
} |
... | ... |
@@ -1394,6 +1473,60 @@ public class Blimp extends JApplet |
1394 | 1473 |
textColorsColor.setText( hex.toUpperCase( ) ); |
1395 | 1474 |
} |
1396 | 1475 |
|
1476 |
+ //gray predefined colors have been chosen |
|
1477 |
+ private void actionColorsPredefGray( ) |
|
1478 |
+ { |
|
1479 |
+ int i, val; |
|
1480 |
+ |
|
1481 |
+ //update color buttons |
|
1482 |
+ for( i = 0; i < constColorCnt; i++ ) |
|
1483 |
+ { |
|
1484 |
+ val = (constColorCnt - 1 - i) * 255 / (constColorCnt - 1); |
|
1485 |
+ colors[i] = new Color( val, val, val ); |
|
1486 |
+ iconFromColor( iconsColor[i], colors[i] ); |
|
1487 |
+ buttonsColor[i].repaint( ); |
|
1488 |
+ } |
|
1489 |
+ |
|
1490 |
+ //update current color |
|
1491 |
+ showColorsColor( ); |
|
1492 |
+ frameEditor.setColor( colors[colorIdx] ); |
|
1493 |
+ } |
|
1494 |
+ |
|
1495 |
+ //colorful predefined colors have been chosen |
|
1496 |
+ private void actionColorsPredefColor( ) |
|
1497 |
+ { |
|
1498 |
+ int i, val, step; |
|
1499 |
+ |
|
1500 |
+ //update color buttons |
|
1501 |
+ for( i = 0; i < constColorCnt; i++ ) |
|
1502 |
+ { |
|
1503 |
+ if( i == 0 ) |
|
1504 |
+ colors[i] = new Color( 255, 255, 255 ); |
|
1505 |
+ else if( i == 1 ) |
|
1506 |
+ colors[i] = new Color( 0, 0, 0 ); |
|
1507 |
+ else |
|
1508 |
+ { |
|
1509 |
+ val = (i - 2) * 6 * 255 / (constColorCnt - 2); |
|
1510 |
+ step = val / 255; |
|
1511 |
+ val %= 255; |
|
1512 |
+ switch( step ) { |
|
1513 |
+ case 0: colors[i] = new Color( 255, val, 0 ); break; |
|
1514 |
+ case 1: colors[i] = new Color( 255 - val, 255, 0 ); break; |
|
1515 |
+ case 2: colors[i] = new Color( 0, 255, val ); break; |
|
1516 |
+ case 3: colors[i] = new Color( 0, 255 - val, 255 ); break; |
|
1517 |
+ case 4: colors[i] = new Color( val, 0, 255 ); break; |
|
1518 |
+ case 5: colors[i] = new Color( 255, 0, 255 - val ); break; |
|
1519 |
+ } |
|
1520 |
+ } |
|
1521 |
+ iconFromColor( iconsColor[i], colors[i] ); |
|
1522 |
+ buttonsColor[i].repaint( ); |
|
1523 |
+ } |
|
1524 |
+ |
|
1525 |
+ //update current color |
|
1526 |
+ showColorsColor( ); |
|
1527 |
+ frameEditor.setColor( colors[colorIdx] ); |
|
1528 |
+ } |
|
1529 |
+ |
|
1397 | 1530 |
//color select button was pressed |
1398 | 1531 |
private void actionColorsColor( ) |
1399 | 1532 |
{ |
... | ... |
@@ -1619,10 +1752,10 @@ public class Blimp extends JApplet |
1619 | 1752 |
actionInfoAdd( ); |
1620 | 1753 |
else if( e.getSource( ) == menuInfoDelete ) |
1621 | 1754 |
actionInfoDelete( ); |
1622 |
- else if( e.getSource( ) == menuEditResize ) |
|
1623 |
- actionEditResize( ); |
|
1624 |
- else if( e.getSource( ) == menuEditScale ) |
|
1625 |
- actionEditScale( ); |
|
1755 |
+ else if( e.getSource( ) == menuEditResizeUser ) |
|
1756 |
+ actionEditResizeUser( ); |
|
1757 |
+ else if( e.getSource( ) == menuEditScaleUser ) |
|
1758 |
+ actionEditScaleUser( ); |
|
1626 | 1759 |
else if( e.getSource( ) == menuEditInsertFrame ) |
1627 | 1760 |
actionEditInsertFrame( ); |
1628 | 1761 |
else if( e.getSource( ) == menuEditDuplicateFrame ) |
... | ... |
@@ -1717,6 +1850,10 @@ public class Blimp extends JApplet |
1717 | 1850 |
actionEditDuplicateFrame( ); |
1718 | 1851 |
else if( e.getSource( ) == buttonEditDeleteFrame ) |
1719 | 1852 |
actionEditDeleteFrame( ); |
1853 |
+ else if( e.getSource( ) == buttonColorsPredefGray ) |
|
1854 |
+ actionColorsPredefGray( ); |
|
1855 |
+ else if( e.getSource( ) == buttonColorsPredefColor ) |
|
1856 |
+ actionColorsPredefColor( ); |
|
1720 | 1857 |
else if( e.getSource( ) == buttonColorsColor ) |
1721 | 1858 |
actionColorsColor( ); |
1722 | 1859 |
else if( e.getSource( ) == textColorsColor ) |
... | ... |
@@ -1725,11 +1862,35 @@ public class Blimp extends JApplet |
1725 | 1862 |
validateColorsAlpha( ); |
1726 | 1863 |
else |
1727 | 1864 |
{ |
1865 |
+ do //abuse of break |
|
1866 |
+ { |
|
1867 |
+ for( i = 0; i < menuEditResizeKnown.length; i++ ) |
|
1868 |
+ if( e.getSource( ) == menuEditResizeKnown[i] ) |
|
1869 |
+ break; |
|
1870 |
+ if( i < menuEditResizeKnown.length ) |
|
1871 |
+ { |
|
1872 |
+ actionEditResizeToFormat( getFormatOrSize( knownFormats[i] ) ); |
|
1873 |
+ break; |
|
1874 |
+ } |
|
1875 |
+ |
|
1876 |
+ for( i = 0; i < menuEditScaleKnown.length; i++ ) |
|
1877 |
+ if( e.getSource( ) == menuEditScaleKnown[i] ) |
|
1878 |
+ break; |
|
1879 |
+ if( i < menuEditScaleKnown.length ) |
|
1880 |
+ { |
|
1881 |
+ actionEditScaleToSize( getFormatOrSize( knownSizes[i] ) ); |
|
1882 |
+ break; |
|
1883 |
+ } |
|
1884 |
+ |
|
1728 | 1885 |
for( i = 0; i < constColorCnt; i++ ) |
1729 | 1886 |
if( e.getSource( ) == buttonsColor[i] ) |
1730 | 1887 |
break; |
1731 | 1888 |
if( i < constColorCnt ) |
1889 |
+ { |
|
1732 | 1890 |
actionColorIdx( i ); |
1891 |
+ break; |
|
1892 |
+ } |
|
1893 |
+ } while( false ); //end abuse of break |
|
1733 | 1894 |
} |
1734 | 1895 |
} |
1735 | 1896 |
|
... | ... |
@@ -1846,12 +2007,13 @@ public class Blimp extends JApplet |
1846 | 2007 |
{ |
1847 | 2008 |
int i, val; |
1848 | 2009 |
Dimension size; |
2010 |
+ ImageIcon icon; |
|
1849 | 2011 |
Insets smallMargin; |
1850 | 2012 |
|
1851 | 2013 |
//initialize current movie, frame |
1852 | 2014 |
curDir = new File( "." ); |
1853 | 2015 |
curMovie = new BlinkenMovie( defHeight, defWidth, defChannels, defMaxval ); |
1854 |
- curMovie.insertInfo( 0, "creator", "Blimp (version 1.3.1 date 2006-10-17)" ); |
|
2016 |
+ curMovie.insertInfo( 0, "creator", "Blimp (version 1.3.2 date 2008-02-23)" ); |
|
1855 | 2017 |
curMovie.insertFrame( 0, new BlinkenFrame( defHeight, defWidth, defChannels, defMaxval, defDuration ) ); |
1856 | 2018 |
curFrame = null; |
1857 | 2019 |
|
... | ... |
@@ -1940,14 +2102,34 @@ public class Blimp extends JApplet |
1940 | 2102 |
menuEdit = new JMenu( "Edit" ); |
1941 | 2103 |
menuEdit.setMnemonic( KeyEvent.VK_E ); |
1942 | 2104 |
menubar.add( menuEdit ); |
1943 |
- menuEditResize = new JMenuItem( "Resize Movie..." ); |
|
1944 |
- menuEditResize.setMnemonic( KeyEvent.VK_R ); |
|
1945 |
- menuEditResize.addActionListener( this ); |
|
2105 |
+ menuEditResize = new JMenu("Resize Movie"); |
|
1946 | 2106 |
menuEdit.add( menuEditResize ); |
1947 |
- menuEditScale = new JMenuItem( "Scale Movie..." ); |
|
1948 |
- menuEditScale.setMnemonic( KeyEvent.VK_S ); |
|
1949 |
- menuEditScale.addActionListener( this ); |
|
2107 |
+ menuEditResize.setMnemonic( KeyEvent.VK_R ); |
|
2108 |
+ menuEditResizeUser = new JMenuItem( "user defined format..." ); |
|
2109 |
+ menuEditResizeUser.addActionListener( this ); |
|
2110 |
+ menuEditResize.add( menuEditResizeUser ); |
|
2111 |
+ menuEditResize.addSeparator( ); |
|
2112 |
+ menuEditResizeKnown = new JMenuItem[knownFormats.length]; |
|
2113 |
+ for( i = 0; i < knownFormats.length; i++ ) |
|
2114 |
+ { |
|
2115 |
+ menuEditResizeKnown[i] = new JMenuItem( knownFormats[i] ); |
|
2116 |
+ menuEditResizeKnown[i].addActionListener( this ); |
|
2117 |
+ menuEditResize.add( menuEditResizeKnown[i] ); |
|
2118 |
+ } |
|
2119 |
+ menuEditScale = new JMenu ( "Scale Movie" ); |
|
1950 | 2120 |
menuEdit.add( menuEditScale ); |
2121 |
+ menuEditScale.setMnemonic( KeyEvent.VK_S ); |
|
2122 |
+ menuEditScaleUser = new JMenuItem( "user defined size..." ); |
|
2123 |
+ menuEditScaleUser.addActionListener( this ); |
|
2124 |
+ menuEditScale.add( menuEditScaleUser ); |
|
2125 |
+ menuEditScale.addSeparator( ); |
|
2126 |
+ menuEditScaleKnown = new JMenuItem[knownSizes.length]; |
|
2127 |
+ for( i = 0; i < knownSizes.length; i++ ) |
|
2128 |
+ { |
|
2129 |
+ menuEditScaleKnown[i] = new JMenuItem( knownSizes[i] ); |
|
2130 |
+ menuEditScaleKnown[i].addActionListener( this ); |
|
2131 |
+ menuEditScale.add( menuEditScaleKnown[i] ); |
|
2132 |
+ } |
|
1951 | 2133 |
menuEdit.addSeparator( ); |
1952 | 2134 |
menuEditInsertFrame = new JMenuItem( "Insert Frame" ); |
1953 | 2135 |
menuEditInsertFrame.setMnemonic( KeyEvent.VK_I ); |
... | ... |
@@ -2346,8 +2528,18 @@ public class Blimp extends JApplet |
2346 | 2528 |
panelColorsChoose.add( buttonsColor[i] ); |
2347 | 2529 |
} |
2348 | 2530 |
//color panel - settings |
2349 |
- panelColorsSettings = new JPanel( new GridLayout( 4, 1, 5, 0 ) ); |
|
2531 |
+ panelColorsSettings = new JPanel( new GridLayout( 5, 1, 5, 0 ) ); |
|
2350 | 2532 |
panelColors.add( panelColorsSettings ); |
2533 |
+ panelColorsPredef = new JPanel( new GridLayout( 1, 2, 5, 5 ) ); |
|
2534 |
+ buttonColorsPredefGray = new JButton( ); |
|
2535 |
+ buttonColorsPredefGray.addActionListener( this ); |
|
2536 |
+ buttonColorsPredefGray.setToolTipText( "gray" ); |
|
2537 |
+ panelColorsPredef.add( buttonColorsPredefGray ); |
|
2538 |
+ buttonColorsPredefColor = new JButton( ); |
|
2539 |
+ buttonColorsPredefColor.addActionListener( this ); |
|
2540 |
+ buttonColorsPredefColor.setToolTipText( "color" ); |
|
2541 |
+ panelColorsPredef.add( buttonColorsPredefColor ); |
|
2542 |
+ panelColorsSettings.add( panelColorsPredef ); |
|
2351 | 2543 |
labelColorsColor = new JLabel( "color:" ); |
2352 | 2544 |
labelColorsColor.setVerticalAlignment( JLabel.BOTTOM ); |
2353 | 2545 |
panelColorsSettings.add( labelColorsColor ); |
... | ... |
@@ -2381,24 +2573,29 @@ public class Blimp extends JApplet |
2381 | 2573 |
textColorsAlpha.addFocusListener( this ); |
2382 | 2574 |
panelColorsAlpha.add( textColorsAlpha ); |
2383 | 2575 |
labelColorsAlpha.setLabelFor( panelColorsAlpha ); |
2384 |
- //color panel - color icons |
|
2576 |
+ |
|
2577 |
+ //initialize colors |
|
2385 | 2578 |
colorIdx = 0; |
2386 | 2579 |
colors = new Color[constColorCnt]; |
2387 |
- size = textColorsAlpha.getPreferredSize( ); |
|
2388 | 2580 |
iconsColor = new ImageIcon[constColorCnt]; |
2581 |
+ size = textColorsAlpha.getPreferredSize( ); |
|
2389 | 2582 |
for( i = 0; i < constColorCnt; i++ ) |
2390 | 2583 |
{ |
2391 | 2584 |
iconsColor[i] = new ImageIcon( new BufferedImage( size.width, size.height, BufferedImage.TYPE_INT_RGB ) ); |
2392 |
- val = (constColorCnt - 1 - i) * 255 / (constColorCnt - 1); |
|
2393 |
- colors[i] = new Color( val, val, val ); |
|
2394 |
- iconFromColor( iconsColor[i], colors[i] ); |
|
2585 |
+ buttonsColor[i].setIcon( iconsColor[i] ); |
|
2395 | 2586 |
buttonsColor[i].setIcon( iconsColor[i] ); |
2396 | 2587 |
} |
2588 |
+ icon = new ImageIcon( new BufferedImage( size.width, size.height, BufferedImage.TYPE_INT_RGB ) ); |
|
2589 |
+ iconGradientGray( icon ); |
|
2590 |
+ buttonColorsPredefGray.setIcon( icon ); |
|
2591 |
+ icon = new ImageIcon( new BufferedImage( size.width, size.height, BufferedImage.TYPE_INT_RGB ) ); |
|
2592 |
+ iconGradientColor( icon ); |
|
2593 |
+ buttonColorsPredefColor.setIcon( icon ); |
|
2397 | 2594 |
iconColorsColor = new ImageIcon( new BufferedImage( size.width, size.height, BufferedImage.TYPE_INT_RGB ) ); |
2398 |
- iconFromColor( iconColorsColor, colors[colorIdx] ); |
|
2399 | 2595 |
buttonColorsColor.setIcon( iconColorsColor ); |
2400 | 2596 |
buttonsColor[colorIdx].setSelected( true ); |
2401 | 2597 |
frameEditor.setColor( colors[colorIdx] ); |
2598 |
+ actionColorsPredefGray( ); |
|
2402 | 2599 |
|
2403 | 2600 |
//create play timer |
2404 | 2601 |
timerPlay = new javax.swing.Timer( 100, this ); |
... | ... |
@@ -2471,11 +2668,10 @@ public class Blimp extends JApplet |
2471 | 2668 |
|
2472 | 2669 |
//running as command line tool |
2473 | 2670 |
System.out.println( "BlinkenLightsInteractiveMovieProgram\n" + |
2474 |
- "version 1.3.1 date 2006-10-17\n" + |
|
2475 |
- "Copyright (C) 2004-2006: Stefan Schuermans <1stein@schuermans.info>\n" + |
|
2671 |
+ "version 1.3.2 date 2008-02-23\n" + |
|
2672 |
+ "Copyright (C) 2004-2008: Stefan Schuermans <stefan@schuermans.info>\n" + |
|
2476 | 2673 |
"Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html\n" + |
2477 |
- "a blinkenarea.org project\n" + |
|
2478 |
- "powered by eventphone.de\n" ); |
|
2674 |
+ "a blinkenarea.org project\n" ); |
|
2479 | 2675 |
|
2480 | 2676 |
//initialize patterns |
2481 | 2677 |
sizePattern = Pattern.compile( "^([0-9]+)x([0-9]+)-([0-9]+)/([0-9]+)$" ); |
... | ... |
@@ -2483,7 +2679,7 @@ public class Blimp extends JApplet |
2483 | 2679 |
|
2484 | 2680 |
//get initial movie |
2485 | 2681 |
movie = new BlinkenMovie( defHeight, defWidth, defChannels, defMaxval ); |
2486 |
- movie.insertInfo( 0, "creator", "Blimp (version 1.3.1 date 2006-10-17)" ); |
|
2682 |
+ movie.insertInfo( 0, "creator", "Blimp (version 1.3.2 date 2008-02-23)" ); |
|
2487 | 2683 |
movie.insertFrame( 0, new BlinkenFrame( defHeight, defWidth, defChannels, defMaxval, defDuration ) ); |
2488 | 2684 |
|
2489 | 2685 |
//process parameters |
... | ... |
@@ -1,9 +1,8 @@ |
1 | 1 |
/* BlinkenLightsInteractiveMovieProgram |
2 |
- * version 1.3.1 date 2006-10-17 |
|
3 |
- * Copyright (C) 2004-2006: Stefan Schuermans <1stein@schuermans.info> |
|
2 |
+ * version 1.3.2 date 2008-02-23 |
|
3 |
+ * Copyright (C) 2004-2008: Stefan Schuermans <stefan@schuermans.info> |
|
4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
5 | 5 |
* a blinkenarea.org project |
6 |
- * powered by eventphone.de |
|
7 | 6 |
*/ |
8 | 7 |
|
9 | 8 |
package org.blinkenarea.Blimp; |
... | ... |
@@ -1,9 +1,8 @@ |
1 | 1 |
/* BlinkenLightsInteractiveMovieProgram |
2 |
- * version 1.3.1 date 2006-10-17 |
|
3 |
- * Copyright (C) 2004-2006: Stefan Schuermans <1stein@schuermans.info> |
|
2 |
+ * version 1.3.2 date 2008-02-23 |
|
3 |
+ * Copyright (C) 2004-2008: Stefan Schuermans <stefan@schuermans.info> |
|
4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
5 | 5 |
* a blinkenarea.org project |
6 |
- * powered by eventphone.de |
|
7 | 6 |
*/ |
8 | 7 |
|
9 | 8 |
package org.blinkenarea.Blimp; |
... | ... |
@@ -1,9 +1,8 @@ |
1 | 1 |
/* BlinkenLightsInteractiveMovieProgram |
2 |
- * version 1.3.1 date 2006-10-17 |
|
3 |
- * Copyright (C) 2004-2006: Stefan Schuermans <1stein@schuermans.info> |
|
2 |
+ * version 1.3.2 date 2008-02-23 |
|
3 |
+ * Copyright (C) 2004-2008: Stefan Schuermans <stefan@schuermans.info> |
|
4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
5 | 5 |
* a blinkenarea.org project |
6 |
- * powered by eventphone.de |
|
7 | 6 |
*/ |
8 | 7 |
|
9 | 8 |
package org.blinkenarea.Blimp; |
... | ... |
@@ -1,9 +1,8 @@ |
1 | 1 |
/* BlinkenLightsInteractiveMovieProgram |
2 |
- * version 1.3.1 date 2006-10-17 |
|
3 |
- * Copyright (C) 2004-2006: Stefan Schuermans <1stein@schuermans.info> |
|
2 |
+ * version 1.3.2 date 2008-02-23 |
|
3 |
+ * Copyright (C) 2004-2008: Stefan Schuermans <stefan@schuermans.info> |
|
4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
5 | 5 |
* a blinkenarea.org project |
6 |
- * powered by eventphone.de |
|
7 | 6 |
*/ |
8 | 7 |
|
9 | 8 |
package org.blinkenarea.Blimp; |
... | ... |
@@ -1,9 +1,8 @@ |
1 | 1 |
/* BlinkenLightsInteractiveMovieProgram |
2 |
- * version 1.3.1 date 2006-10-17 |
|
3 |
- * Copyright (C) 2004-2006: Stefan Schuermans <1stein@schuermans.info> |
|
2 |
+ * version 1.3.2 date 2008-02-23 |
|
3 |
+ * Copyright (C) 2004-2008: Stefan Schuermans <stefan@schuermans.info> |
|
4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
5 | 5 |
* a blinkenarea.org project |
6 |
- * powered by eventphone.de |
|
7 | 6 |
*/ |
8 | 7 |
|
9 | 8 |
package org.blinkenarea.Blimp; |
... | ... |
@@ -1,9 +1,8 @@ |
1 | 1 |
/* BlinkenLightsInteractiveMovieProgram |
2 |
- * version 1.3.1 date 2006-10-17 |
|
3 |
- * Copyright (C) 2004-2006: Stefan Schuermans <1stein@schuermans.info> |
|
2 |
+ * version 1.3.2 date 2008-02-23 |
|
3 |
+ * Copyright (C) 2004-2008: Stefan Schuermans <stefan@schuermans.info> |
|
4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
5 | 5 |
* a blinkenarea.org project |
6 |
- * powered by eventphone.de |
|
7 | 6 |
*/ |
8 | 7 |
|
9 | 8 |
package org.blinkenarea.Blimp; |
10 | 9 |