mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-12-24 23:31:31 +00:00
Colours menu
This commit is contained in:
parent
263b687559
commit
a91d26684e
@ -1,7 +1,5 @@
|
||||
package com.bytezone.diskbrowser.applefile;
|
||||
|
||||
import static com.bytezone.diskbrowser.applefile.HiResImage.palette;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBuffer;
|
||||
|
||||
@ -17,7 +15,6 @@ public class DoubleHiResImage extends HiResImage
|
||||
public DoubleHiResImage (String name, byte[] buffer, byte[] auxBuffer)
|
||||
{
|
||||
super (name, buffer);
|
||||
// switchColours ();
|
||||
|
||||
this.auxBuffer = auxBuffer;
|
||||
createImage ();
|
||||
@ -26,7 +23,6 @@ public class DoubleHiResImage extends HiResImage
|
||||
public DoubleHiResImage (String name, byte[] buffer)
|
||||
{
|
||||
super (name, buffer);
|
||||
// switchColours ();
|
||||
|
||||
assert name.endsWith (".PAC") || name.endsWith ("A2FC");
|
||||
|
||||
@ -87,7 +83,8 @@ public class DoubleHiResImage extends HiResImage
|
||||
@Override
|
||||
protected void createColourImage ()
|
||||
{
|
||||
int paletteNdx = paletteIndex % palette.length;
|
||||
Palette palette = paletteFactory.getCurrentPalette ();
|
||||
int[] colours = palette.getColours ();
|
||||
|
||||
// image will be doubled horizontally
|
||||
image = new BufferedImage (140 * 2, 192, BufferedImage.TYPE_INT_RGB);
|
||||
@ -108,8 +105,8 @@ public class DoubleHiResImage extends HiResImage
|
||||
for (int px = 0; px < 28; px += 4)
|
||||
{
|
||||
int val = (value >> px) & 0x0F;
|
||||
dataBuffer.setElem (ndx++, palette[paletteNdx][val]);
|
||||
dataBuffer.setElem (ndx++, palette[paletteNdx][val]); // repeat pixel
|
||||
dataBuffer.setElem (ndx++, colours[val]);
|
||||
dataBuffer.setElem (ndx++, colours[val]); // repeat pixel
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,176 +4,24 @@ import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import com.bytezone.diskbrowser.applefile.PaletteFactory.CycleDirection;
|
||||
import com.bytezone.diskbrowser.prodos.ProdosConstants;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
public abstract class HiResImage extends AbstractFile
|
||||
{
|
||||
protected static int[][] //
|
||||
palette = {
|
||||
// my preferences
|
||||
{ 0x000000, // 0 black A
|
||||
0xFF0000, // 1 red C
|
||||
0xA52A2A, // 2 brown E (8)
|
||||
0xFFA500, // 3 orange G (9)
|
||||
0x008000, // 4 dark green I
|
||||
0x808080, // 5 grey1 K
|
||||
0x90EE90, // 6 light green M (C)
|
||||
0xFFFF00, // 7 yellow O (D)
|
||||
0x00008B, // 8 dark blue B (2)
|
||||
0x800080, // 9 purple D (3)
|
||||
0xC0C0C0, // A grey2 F
|
||||
0xFFC0CB, // B pink H
|
||||
0x00BFFF, // C med blue J (6)
|
||||
0x87CEFA, // D light blue L (7)
|
||||
0x00FFFF, // E aqua N
|
||||
0xFFFFFF // F white P
|
||||
},
|
||||
// Virtual II
|
||||
{ 0x000000, // 0 black
|
||||
0xDD0033, // 1 magenta
|
||||
0x885500, // 2 brown (8)
|
||||
0xFF6600, // 3 orange (9)
|
||||
0x007722, // 4 dark green
|
||||
0x555555, // 5 grey1
|
||||
0x11DD00, // 6 light green (C)
|
||||
0xFFFF00, // 7 yellow (D)
|
||||
0x000099, // 8 dark blue (2)
|
||||
0xDD22DD, // 9 purple (3)
|
||||
0xAAAAAA, // A grey2
|
||||
0xFF9988, // B pink
|
||||
0x2222FF, // C med blue (6)
|
||||
0x66AAFF, // D light blue (7)
|
||||
0x44FF99, // E aqua
|
||||
0xFFFFFF // F white
|
||||
},
|
||||
// Bill Buckels
|
||||
{ 0x000000, // 0 black
|
||||
0x9D0966, // 1 red
|
||||
0x555500, // 2 brown
|
||||
0xF25E00, // 3 orange
|
||||
0x00761A, // 4 dk green
|
||||
0x808080, // 5 gray
|
||||
0x38CB00, // 6 lt green
|
||||
0xD5D51A, // 7 yellow
|
||||
0x2A2AE5, // 8 dk blue
|
||||
0xC734FF, // 9 purple
|
||||
0xC0C0C0, // A grey
|
||||
0xFF89E5, // B pink
|
||||
0x0DA1FF, // C med blue
|
||||
0xAAAAFF, // D lt blue
|
||||
0x62F699, // E aqua
|
||||
0xFFFFFF // F white
|
||||
},
|
||||
// Kegs (BB)
|
||||
{ rgb (0, 0, 0), // black */
|
||||
rgb (221, 0, 51), // red */
|
||||
rgb (136, 85, 34), // brown */
|
||||
rgb (255, 102, 0), // orange */
|
||||
rgb (0, 119, 0), // dk green */
|
||||
rgb (85, 85, 85), // gray */
|
||||
rgb (0, 221, 0), // lt green */
|
||||
rgb (255, 255, 0), // yellow */
|
||||
rgb (0, 0, 153), // dk blue */
|
||||
rgb (221, 0, 221), // purple */
|
||||
rgb (170, 170, 170), // grey */
|
||||
rgb (255, 153, 136), // pink */
|
||||
rgb (34, 34, 255), // med blue */
|
||||
rgb (102, 170, 255), // lt blue */
|
||||
rgb (0, 255, 153), // aqua */
|
||||
rgb (255, 255, 255) // white
|
||||
},
|
||||
// Authentic (MP)
|
||||
{ 0x000000, // black
|
||||
0xD00030, // magenta
|
||||
0x805000, // brown
|
||||
0xF06000, // orange
|
||||
0x007020, // dark green
|
||||
0x505050, // grey1
|
||||
0x10D000, // light green
|
||||
0xF0F000, // yellow
|
||||
0x000090, // dark blue
|
||||
0xD020D0, // purple
|
||||
0xA0A0A0, // grey2
|
||||
0xF09080, // pink
|
||||
0x2020F0, // med blue
|
||||
0x60A0F0, // light blue
|
||||
0x40F090, // aqua
|
||||
0xFFFFFF // white
|
||||
},
|
||||
// Tweaked (MP)
|
||||
{ 0x000000, // black
|
||||
0xD00030, // magenta
|
||||
0x805000, // brown
|
||||
0xFF8000, // orange
|
||||
0x008000, // dark green
|
||||
0x808080, // grey1
|
||||
0x00FF00, // light green
|
||||
0xFFFF00, // yellow
|
||||
0x000080, // dark blue
|
||||
0xFF00FF, // purple
|
||||
0xC0C0C0, // grey2
|
||||
0xFF9080, // pink
|
||||
0x0000FF, // med blue
|
||||
0x60A0FF, // light blue
|
||||
0x40FF90, // aqua
|
||||
0xFFFFFF // white
|
||||
},
|
||||
// NTSC Corrected (MP)
|
||||
{ 0x000000, // black
|
||||
0x901740, // magenta
|
||||
0x405400, // brown
|
||||
0xD06A1A, // orange
|
||||
0x006940, // dark green
|
||||
0x808080, // grey1
|
||||
0x2FBC1A, // light green
|
||||
0xBFD35A, // yellow
|
||||
0x402CA5, // dark blue
|
||||
0xD043E5, // purple
|
||||
0x808080, // grey2
|
||||
0xFF96BF, // pink
|
||||
0x2F95E5, // med blue
|
||||
0xBFABFF, // light blue
|
||||
0x6FE8BF, // aqua
|
||||
0xFFFFFF // white
|
||||
}, };
|
||||
protected static PaletteFactory paletteFactory = new PaletteFactory ();
|
||||
|
||||
/*-
|
||||
* Michael Pohoreski - The Apple II Forever Anthology
|
||||
|
||||
@reference: Technote tn-iigs-063 “Master Color Values”
|
||||
Color Register Values
|
||||
Color Reg LR HR DHR Master Authentic Tweaked NTSC
|
||||
Name # # # Value Corrected
|
||||
-----------------------------------------------------------------------------
|
||||
Black 0 0 0,4 0 $0000 (00,00,00) (00,00,00) 00,00,00
|
||||
(Magenta) Deep Red 1 1 1 $0D03 (D0,00,30) (D0,00,30) 90,17,40
|
||||
Dark Blue 2 2 8 $0009 (00,00,90) (00,00,80) 40,2C,A5
|
||||
(Violet) Purple 3 3 2 9 $0D2D (D0,20,D0) (FF,00,FF) D0,43,E5
|
||||
Dark Green 4 4 4 $0072 (00,70,20) (00,80,00) 00,69,40
|
||||
(Gray 1) Dark Gray 5 5 5 $0555 (50,50,50) (80,80,80) 80,80,80
|
||||
(Blue) Medium Blue 6 6 6 C $022F (20,20,F0) (00,00,FF) 2F,95,E5
|
||||
(Cyan) Light Blue 7 7 D $06AF (60,A0,F0) (60,A0,FF) BF,AB,FF
|
||||
Brown 8 8 2 $0850 (80,50,00) (80,50,00) 40,54,00
|
||||
Orange 9 9 5 3 $0F60 (F0,60,00) (FF,80,00) D0,6A,1A
|
||||
(Gray 2) Light Gray A A A $0AAA (A0,A0,A0) (C0,C0,C0) 80,80,80
|
||||
Pink B B B $0F98 (F0,90,80) (FF,90,80) FF,96,BF
|
||||
(Green) Light Green C C 1 6 $01D0 (10,D0,00) (00,FF,00) 2F,BC,1A
|
||||
Yellow D D 7 $0FF0 (F0,F0,00) (FF,FF,00) BF,D3,5A
|
||||
(Aqua) Aquamarine E E E $04F9 (40,F0,90) (40,FF,90) 6F,E8,BF
|
||||
White F F 3,7 F $0FFF (F0,F0,F0) (FF,FF,FF) FF,FF,FF
|
||||
Legend:
|
||||
LR: Lo-Res HR: Hi-Res DHR: Double Hi-Res
|
||||
*/
|
||||
private static final byte[] pngHeader =
|
||||
{ (byte) 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A };
|
||||
|
||||
protected static boolean colourQuirks;
|
||||
protected static boolean monochrome;
|
||||
protected static int paletteIndex;
|
||||
// protected Palette palette;
|
||||
|
||||
protected int fileType;
|
||||
protected int auxType;
|
||||
@ -182,6 +30,7 @@ public abstract class HiResImage extends AbstractFile
|
||||
public HiResImage (String name, byte[] buffer)
|
||||
{
|
||||
super (name, buffer);
|
||||
// palette = paletteFactory.getCurrentPalette ();
|
||||
}
|
||||
|
||||
public HiResImage (String name, byte[] buffer, int loadAddress)
|
||||
@ -236,13 +85,21 @@ public abstract class HiResImage extends AbstractFile
|
||||
|
||||
protected abstract void createColourImage ();
|
||||
|
||||
public void cyclePalette ()
|
||||
public void setPalette (Palette palette)
|
||||
{
|
||||
++paletteIndex;
|
||||
paletteFactory.setCurrentPalette (palette);
|
||||
if (!monochrome)
|
||||
createImage ();
|
||||
}
|
||||
|
||||
public Palette cyclePalette (CycleDirection direction)
|
||||
{
|
||||
Palette palette = paletteFactory.cyclePalette (direction);
|
||||
if (!monochrome)
|
||||
createImage ();
|
||||
return palette;
|
||||
}
|
||||
|
||||
public void setColourQuirks (boolean value)
|
||||
{
|
||||
if (colourQuirks == value)
|
||||
@ -477,24 +334,13 @@ public abstract class HiResImage extends AbstractFile
|
||||
return true;
|
||||
}
|
||||
|
||||
// switch between lo-res and DHR indexing
|
||||
private void switchColours ()
|
||||
public static PaletteFactory getPaletteFactory ()
|
||||
{
|
||||
int[] tbl = { 2, 3, 6, 7 };
|
||||
for (int i = 0; i < palette.length; i++)
|
||||
for (int j = 0; j < tbl.length; j++)
|
||||
{
|
||||
int c = tbl[j];
|
||||
int temp = palette[i][c];
|
||||
palette[i][c] = palette[i][c + 6];
|
||||
palette[i][c + 6] = temp;
|
||||
}
|
||||
return paletteFactory;
|
||||
}
|
||||
|
||||
private static int rgb (int red, int green, int blue)
|
||||
public static List<Palette> getPalettes ()
|
||||
{
|
||||
System.out.printf ("%3d %3d %3d = 0x%06X%n", red, green, blue,
|
||||
(red << 16 | green << 8 | blue));
|
||||
return red << 16 | green << 8 | blue;
|
||||
return paletteFactory.getPalettes ();
|
||||
}
|
||||
}
|
@ -89,7 +89,8 @@ public class OriginalHiResImage extends HiResImage
|
||||
|
||||
private void fillLine (int base)
|
||||
{
|
||||
int paletteNdx = paletteIndex % palette.length;
|
||||
Palette palette = paletteFactory.getCurrentPalette ();
|
||||
int[] colours = palette.getColours ();
|
||||
|
||||
int max = Math.min (base + 40, buffer.length);
|
||||
int linePtr = 0;
|
||||
@ -107,7 +108,7 @@ public class OriginalHiResImage extends HiResImage
|
||||
int column = (ptr + px) % 2; // is it in an odd or even column?
|
||||
line[linePtr++] = val == 0 ? 0 : // black pixel
|
||||
// palette[colourBit][column]; // coloured pixel - use lookup table
|
||||
palette[paletteNdx][paletteTable[colourBit][column]]; // coloured pixel - use lookup table
|
||||
colours[paletteTable[colourBit][column]]; // coloured pixel - use lookup table
|
||||
}
|
||||
}
|
||||
|
||||
|
56
src/com/bytezone/diskbrowser/applefile/Palette.java
Normal file
56
src/com/bytezone/diskbrowser/applefile/Palette.java
Normal file
@ -0,0 +1,56 @@
|
||||
package com.bytezone.diskbrowser.applefile;
|
||||
|
||||
public class Palette
|
||||
{
|
||||
/*-
|
||||
* Michael Pohoreski - The Apple II Forever Anthology
|
||||
|
||||
@reference: Technote tn-iigs-063 “Master Color Values”
|
||||
Color Register Values
|
||||
Color Reg LR HR DHR Master Authentic Tweaked NTSC
|
||||
Name # # # Value Corrected
|
||||
-----------------------------------------------------------------------------
|
||||
Black 0 0 0,4 0 $0000 (00,00,00) (00,00,00) 00,00,00
|
||||
(Magenta) Deep Red 1 1 1 $0D03 (D0,00,30) (D0,00,30) 90,17,40
|
||||
Dark Blue 2 2 8 $0009 (00,00,90) (00,00,80) 40,2C,A5
|
||||
(Violet) Purple 3 3 2 9 $0D2D (D0,20,D0) (FF,00,FF) D0,43,E5
|
||||
Dark Green 4 4 4 $0072 (00,70,20) (00,80,00) 00,69,40
|
||||
(Gray 1) Dark Gray 5 5 5 $0555 (50,50,50) (80,80,80) 80,80,80
|
||||
(Blue) Medium Blue 6 6 6 C $022F (20,20,F0) (00,00,FF) 2F,95,E5
|
||||
(Cyan) Light Blue 7 7 D $06AF (60,A0,F0) (60,A0,FF) BF,AB,FF
|
||||
Brown 8 8 2 $0850 (80,50,00) (80,50,00) 40,54,00
|
||||
Orange 9 9 5 3 $0F60 (F0,60,00) (FF,80,00) D0,6A,1A
|
||||
(Gray 2) Light Gray A A A $0AAA (A0,A0,A0) (C0,C0,C0) 80,80,80
|
||||
Pink B B B $0F98 (F0,90,80) (FF,90,80) FF,96,BF
|
||||
(Green) Light Green C C 1 6 $01D0 (10,D0,00) (00,FF,00) 2F,BC,1A
|
||||
Yellow D D 7 $0FF0 (F0,F0,00) (FF,FF,00) BF,D3,5A
|
||||
(Aqua) Aquamarine E E E $04F9 (40,F0,90) (40,FF,90) 6F,E8,BF
|
||||
White F F 3,7 F $0FFF (F0,F0,F0) (FF,FF,FF) FF,FF,FF
|
||||
Legend:
|
||||
LR: Lo-Res HR: Hi-Res DHR: Double Hi-Res
|
||||
*/
|
||||
private final String name;
|
||||
private final int[] colours;
|
||||
|
||||
public Palette (String name, int[] colours)
|
||||
{
|
||||
this.name = name;
|
||||
this.colours = colours;
|
||||
}
|
||||
|
||||
public String getName ()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public int[] getColours ()
|
||||
{
|
||||
return colours;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
return String.format ("Palette: %s", name);
|
||||
}
|
||||
}
|
237
src/com/bytezone/diskbrowser/applefile/PaletteFactory.java
Normal file
237
src/com/bytezone/diskbrowser/applefile/PaletteFactory.java
Normal file
@ -0,0 +1,237 @@
|
||||
package com.bytezone.diskbrowser.applefile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PaletteFactory
|
||||
{
|
||||
private final List<Palette> palettes = new ArrayList<Palette> ();
|
||||
private int currentPalette;
|
||||
|
||||
public PaletteFactory ()
|
||||
{
|
||||
palettes.add (new Palette ("Palette 1",
|
||||
new int[] { 0x000000, // 0 black A
|
||||
0xFF0000, // 1 red C
|
||||
0xA52A2A, // 2 brown E (8)
|
||||
0xFFA500, // 3 orange G (9)
|
||||
0x008000, // 4 dark green I
|
||||
0x808080, // 5 grey1 K
|
||||
0x90EE90, // 6 light green M (C)
|
||||
0xFFFF00, // 7 yellow O (D)
|
||||
0x00008B, // 8 dark blue B (2)
|
||||
0x800080, // 9 purple D (3)
|
||||
0xC0C0C0, // A grey2 F
|
||||
0xFFC0CB, // B pink H
|
||||
0x00BFFF, // C med blue J (6)
|
||||
0x87CEFA, // D light blue L (7)
|
||||
0x00FFFF, // E aqua N
|
||||
0xFFFFFF // F white P
|
||||
}));
|
||||
|
||||
palettes.add (new Palette ("Virtual II",
|
||||
new int[] { 0x000000, // 0 black
|
||||
0xDD0033, // 1 magenta
|
||||
0x885500, // 2 brown (8)
|
||||
0xFF6600, // 3 orange (9)
|
||||
0x007722, // 4 dark green
|
||||
0x555555, // 5 grey1
|
||||
0x11DD00, // 6 light green (C)
|
||||
0xFFFF00, // 7 yellow (D)
|
||||
0x000099, // 8 dark blue (2)
|
||||
0xDD22DD, // 9 purple (3)
|
||||
0xAAAAAA, // A grey2
|
||||
0xFF9988, // B pink
|
||||
0x2222FF, // C med blue (6)
|
||||
0x66AAFF, // D light blue (7)
|
||||
0x44FF99, // E aqua
|
||||
0xFFFFFF // F white
|
||||
}));
|
||||
|
||||
// Applewin new (BB)
|
||||
palettes.add (new Palette ("Applewin (new)",
|
||||
new int[] { 0x000000, // 0 black
|
||||
0x9D0966, // 1 red
|
||||
0x555500, // 2 brown
|
||||
0xF25E00, // 3 orange
|
||||
0x00761A, // 4 dk green
|
||||
0x808080, // 5 gray
|
||||
0x38CB00, // 6 lt green
|
||||
0xD5D51A, // 7 yellow
|
||||
0x2A2AE5, // 8 dk blue
|
||||
0xC734FF, // 9 purple
|
||||
0xC0C0C0, // A grey
|
||||
0xFF89E5, // B pink
|
||||
0x0DA1FF, // C med blue
|
||||
0xAAAAFF, // D lt blue
|
||||
0x62F699, // E aqua
|
||||
0xFFFFFF // F white
|
||||
}));
|
||||
// Applewin old (BB)
|
||||
palettes.add (new Palette ("Applewin (old)",
|
||||
new int[] { rgb (0, 0, 0), // black */
|
||||
rgb (208, 0, 48), // red */
|
||||
rgb (128, 80, 0), // brown */
|
||||
rgb (255, 128, 0), // orange */
|
||||
rgb (0, 128, 0), // dk green */
|
||||
rgb (128, 128, 128), // gray */
|
||||
rgb (0, 255, 0), // lt green */
|
||||
rgb (255, 255, 0), // yellow */
|
||||
rgb (0, 0, 128), // dk blue */
|
||||
rgb (255, 0, 255), // purple */
|
||||
rgb (192, 192, 192), // grey */
|
||||
rgb (255, 144, 128), // pink */
|
||||
rgb (0, 0, 255), // med blue */
|
||||
rgb (96, 160, 255), // lt blue */
|
||||
rgb (64, 255, 144), // aqua */
|
||||
rgb (255, 255, 255) // white
|
||||
}));
|
||||
// Kegs (BB)
|
||||
palettes.add (new Palette ("Kegs",
|
||||
new int[] { rgb (0, 0, 0), // black */
|
||||
rgb (221, 0, 51), // red */
|
||||
rgb (136, 85, 34), // brown */
|
||||
rgb (255, 102, 0), // orange */
|
||||
rgb (0, 119, 0), // dk green */
|
||||
rgb (85, 85, 85), // gray */
|
||||
rgb (0, 221, 0), // lt green */
|
||||
rgb (255, 255, 0), // yellow */
|
||||
rgb (0, 0, 153), // dk blue */
|
||||
rgb (221, 0, 221), // purple */
|
||||
rgb (170, 170, 170), // grey */
|
||||
rgb (255, 153, 136), // pink */
|
||||
rgb (34, 34, 255), // med blue */
|
||||
rgb (102, 170, 255), // lt blue */
|
||||
rgb (0, 255, 153), // aqua */
|
||||
rgb (255, 255, 255) // white
|
||||
}));
|
||||
// Authentic (MP)
|
||||
palettes.add (new Palette ("Authentic",
|
||||
new int[] { 0x000000, // black
|
||||
0xD00030, // magenta
|
||||
0x805000, // brown
|
||||
0xF06000, // orange
|
||||
0x007020, // dark green
|
||||
0x505050, // grey1
|
||||
0x10D000, // light green
|
||||
0xF0F000, // yellow
|
||||
0x000090, // dark blue
|
||||
0xD020D0, // purple
|
||||
0xA0A0A0, // grey2
|
||||
0xF09080, // pink
|
||||
0x2020F0, // med blue
|
||||
0x60A0F0, // light blue
|
||||
0x40F090, // aqua
|
||||
0xFFFFFF // white
|
||||
}));
|
||||
// Tweaked (MP)
|
||||
palettes.add (new Palette ("Tweaked",
|
||||
new int[] { 0x000000, // black
|
||||
0xD00030, // magenta
|
||||
0x805000, // brown
|
||||
0xFF8000, // orange
|
||||
0x008000, // dark green
|
||||
0x808080, // grey1
|
||||
0x00FF00, // light green
|
||||
0xFFFF00, // yellow
|
||||
0x000080, // dark blue
|
||||
0xFF00FF, // purple
|
||||
0xC0C0C0, // grey2
|
||||
0xFF9080, // pink
|
||||
0x0000FF, // med blue
|
||||
0x60A0FF, // light blue
|
||||
0x40FF90, // aqua
|
||||
0xFFFFFF // white
|
||||
}));
|
||||
// NTSC Corrected (MP)
|
||||
palettes.add (new Palette ("NTSC corrected",
|
||||
new int[] { 0x000000, // black
|
||||
0x901740, // magenta
|
||||
0x405400, // brown
|
||||
0xD06A1A, // orange
|
||||
0x006940, // dark green
|
||||
0x808080, // grey1
|
||||
0x2FBC1A, // light green
|
||||
0xBFD35A, // yellow
|
||||
0x402CA5, // dark blue
|
||||
0xD043E5, // purple
|
||||
0x808080, // grey2
|
||||
0xFF96BF, // pink
|
||||
0x2F95E5, // med blue
|
||||
0xBFABFF, // light blue
|
||||
0x6FE8BF, // aqua
|
||||
0xFFFFFF // white
|
||||
}));
|
||||
}
|
||||
|
||||
public enum CycleDirection
|
||||
{
|
||||
FORWARDS, BACKWARDS
|
||||
}
|
||||
|
||||
public Palette cyclePalette (CycleDirection direction)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case FORWARDS:
|
||||
++currentPalette;
|
||||
if (currentPalette >= palettes.size ())
|
||||
currentPalette = 0;
|
||||
break;
|
||||
|
||||
case BACKWARDS:
|
||||
--currentPalette;
|
||||
if (currentPalette < 0)
|
||||
currentPalette = palettes.size () - 1;
|
||||
break;
|
||||
}
|
||||
return getCurrentPalette ();
|
||||
}
|
||||
|
||||
public List<Palette> getPalettes ()
|
||||
{
|
||||
return palettes;
|
||||
}
|
||||
|
||||
public Palette getCurrentPalette ()
|
||||
{
|
||||
return palettes.get (currentPalette);
|
||||
}
|
||||
|
||||
public int getCurrentPaletteIndex ()
|
||||
{
|
||||
return currentPalette;
|
||||
}
|
||||
|
||||
public void setCurrentPalette (int index)
|
||||
{
|
||||
assert index >= 0 && index < palettes.size ();
|
||||
currentPalette = index;
|
||||
}
|
||||
|
||||
public void setCurrentPalette (Palette palette)
|
||||
{
|
||||
int count = 0;
|
||||
for (Palette p : palettes)
|
||||
{
|
||||
if (p == palette)
|
||||
{
|
||||
currentPalette = count;
|
||||
break;
|
||||
}
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
public Palette get (int index)
|
||||
{
|
||||
return palettes.get (index);
|
||||
}
|
||||
|
||||
private int rgb (int red, int green, int blue)
|
||||
{
|
||||
System.out.printf ("%3d %3d %3d = 0x%06X%n", red, green, blue,
|
||||
(red << 16 | green << 8 | blue));
|
||||
return red << 16 | green << 8 | blue;
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ public class ColourQuirksAction extends AbstractAction
|
||||
|
||||
public ColourQuirksAction (DataPanel owner)
|
||||
{
|
||||
super ("Colour quirks");
|
||||
super ("Smear HGR");
|
||||
putValue (Action.SHORT_DESCRIPTION, "Display pixels like a TV screen");
|
||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt Q"));
|
||||
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_Q);
|
||||
|
@ -3,6 +3,7 @@ package com.bytezone.diskbrowser.gui;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
@ -13,6 +14,8 @@ import javax.swing.event.ChangeListener;
|
||||
import com.bytezone.common.FontAction.FontChangeEvent;
|
||||
import com.bytezone.common.FontAction.FontChangeListener;
|
||||
import com.bytezone.diskbrowser.applefile.HiResImage;
|
||||
import com.bytezone.diskbrowser.applefile.Palette;
|
||||
import com.bytezone.diskbrowser.applefile.PaletteFactory.CycleDirection;
|
||||
import com.bytezone.diskbrowser.applefile.VisicalcFile;
|
||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||
import com.bytezone.diskbrowser.disk.SectorList;
|
||||
@ -42,19 +45,10 @@ class DataPanel extends JTabbedPane
|
||||
boolean assemblerTextValid;
|
||||
DataSource currentDataSource;
|
||||
|
||||
// private Font font;
|
||||
final MenuHandler menuHandler;
|
||||
|
||||
public DataPanel (MenuHandler mh, Preferences prefs)
|
||||
{
|
||||
// String dataFontName =
|
||||
// prefs.get (PreferencesDialog.prefsDataFont, PreferencesDialog.defaultFontName);
|
||||
// System.out.println (dataFontName);
|
||||
// int dataFontSize =
|
||||
// prefs.getInt (PreferencesDialog.prefsDataFontSize,
|
||||
// PreferencesDialog.defaultFontSize);
|
||||
// font = new Font (dataFontName, Font.PLAIN, dataFontSize);
|
||||
|
||||
this.menuHandler = mh;
|
||||
setTabPlacement (SwingConstants.BOTTOM);
|
||||
|
||||
@ -80,9 +74,6 @@ class DataPanel extends JTabbedPane
|
||||
imagePane.getVerticalScrollBar ().setUnitIncrement (50);
|
||||
imagePane.getHorizontalScrollBar ().setUnitIncrement (25);
|
||||
|
||||
// setTabsFont (font);
|
||||
// this.setMinimumSize (new Dimension (800, 200));
|
||||
|
||||
addChangeListener (new ChangeListener ()
|
||||
{
|
||||
@Override
|
||||
@ -130,19 +121,43 @@ class DataPanel extends JTabbedPane
|
||||
mh.colourQuirksItem.setAction (new ColourQuirksAction (this));
|
||||
mh.monochromeItem.setAction (new MonochromeAction (this));
|
||||
mh.debuggingItem.setAction (new DebuggingAction (this));
|
||||
mh.paletteItem.setAction (new PaletteAction (this));
|
||||
|
||||
// fill in the placeholders created by the MenuHandler
|
||||
List<Palette> palettes = HiResImage.getPalettes ();
|
||||
ButtonGroup buttonGroup = mh.paletteGroup;
|
||||
Enumeration<AbstractButton> enumeration = buttonGroup.getElements ();
|
||||
int ndx = 0;
|
||||
while (enumeration.hasMoreElements ())
|
||||
{
|
||||
JCheckBoxMenuItem item = (JCheckBoxMenuItem) enumeration.nextElement ();
|
||||
item.setAction (new PaletteAction (this, palettes.get (ndx++)));
|
||||
}
|
||||
mh.nextPaletteItem.setAction (new NextPaletteAction (this, buttonGroup));
|
||||
mh.prevPaletteItem.setAction (new PreviousPaletteAction (this, buttonGroup));
|
||||
}
|
||||
|
||||
public void cyclePalette ()
|
||||
public void selectPalette (Palette palette)
|
||||
{
|
||||
if (currentDataSource instanceof HiResImage)
|
||||
{
|
||||
HiResImage image = (HiResImage) currentDataSource;
|
||||
image.cyclePalette ();
|
||||
image.setPalette (palette);
|
||||
imagePanel.setImage (image.getImage ());
|
||||
}
|
||||
}
|
||||
|
||||
public Palette cyclePalette (CycleDirection direction)
|
||||
{
|
||||
if (currentDataSource instanceof HiResImage)
|
||||
{
|
||||
HiResImage image = (HiResImage) currentDataSource;
|
||||
Palette palette = image.cyclePalette (direction);
|
||||
imagePanel.setImage (image.getImage ());
|
||||
return palette;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setColourQuirks (boolean value)
|
||||
{
|
||||
if (currentDataSource instanceof HiResImage)
|
||||
@ -210,6 +225,7 @@ class DataPanel extends JTabbedPane
|
||||
hexText.setText ("");
|
||||
disassemblyText.setText ("");
|
||||
removeImage ();
|
||||
menuHandler.colourMenu.setEnabled (false);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -244,11 +260,15 @@ class DataPanel extends JTabbedPane
|
||||
|
||||
BufferedImage image = dataSource.getImage ();
|
||||
if (image == null)
|
||||
{
|
||||
removeImage ();
|
||||
menuHandler.colourMenu.setEnabled (false);
|
||||
}
|
||||
else
|
||||
{
|
||||
imagePanel.setImage (image);
|
||||
imagePane.setViewportView (imagePanel);
|
||||
menuHandler.colourMenu.setEnabled (true);
|
||||
if (!imageVisible)
|
||||
{
|
||||
int selected = getSelectedIndex ();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.bytezone.diskbrowser.gui;
|
||||
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
@ -15,9 +16,9 @@ public class DebuggingAction extends AbstractAction
|
||||
public DebuggingAction (DataPanel owner)
|
||||
{
|
||||
super ("Debugging");
|
||||
int mask = Toolkit.getDefaultToolkit ().getMenuShortcutKeyMask ();
|
||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke (KeyEvent.VK_D, mask));
|
||||
putValue (Action.SHORT_DESCRIPTION, "Show debugging information");
|
||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt G"));
|
||||
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_G);
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,8 @@ package com.bytezone.diskbrowser.gui;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
import javax.swing.*;
|
||||
@ -13,6 +15,8 @@ import com.bytezone.common.OSXAdapter;
|
||||
import com.bytezone.common.Platform;
|
||||
import com.bytezone.common.QuitAction.QuitListener;
|
||||
import com.bytezone.diskbrowser.applefile.HiResImage;
|
||||
import com.bytezone.diskbrowser.applefile.Palette;
|
||||
import com.bytezone.diskbrowser.applefile.PaletteFactory;
|
||||
import com.bytezone.diskbrowser.applefile.VisicalcFile;
|
||||
import com.bytezone.diskbrowser.disk.DataDisk;
|
||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
@ -27,12 +31,14 @@ public class MenuHandler
|
||||
private static final String PREFS_COLOUR_QUIRKS = "colour quirks";
|
||||
private static final String PREFS_MONOCHROME = "monochrome";
|
||||
private static final String PREFS_DEBUGGING = "debugging";
|
||||
private static final String PREFS_PALETTE = "palette";
|
||||
|
||||
FormattedDisk currentDisk;
|
||||
|
||||
JMenuBar menuBar = new JMenuBar ();
|
||||
JMenu fileMenu = new JMenu ("File");
|
||||
JMenu formatMenu = new JMenu ("Format");
|
||||
JMenu colourMenu = new JMenu ("Colours");
|
||||
JMenu helpMenu = new JMenu ("Help");
|
||||
|
||||
// File menu items
|
||||
@ -60,12 +66,16 @@ public class MenuHandler
|
||||
JMenuItem colourQuirksItem = new JCheckBoxMenuItem ("Colour quirks");
|
||||
JMenuItem monochromeItem = new JCheckBoxMenuItem ("Monochrome");
|
||||
JMenuItem debuggingItem = new JCheckBoxMenuItem ("Debugging");
|
||||
JMenuItem paletteItem = new JMenuItem ("Cycle Palette");
|
||||
JMenuItem nextPaletteItem = new JMenuItem ("Next Palette");
|
||||
JMenuItem prevPaletteItem = new JMenuItem ("Previous Palette");
|
||||
|
||||
ButtonGroup paletteGroup = new ButtonGroup ();
|
||||
|
||||
public MenuHandler (Preferences prefs)
|
||||
{
|
||||
menuBar.add (fileMenu);
|
||||
menuBar.add (formatMenu);
|
||||
menuBar.add (colourMenu);
|
||||
menuBar.add (helpMenu);
|
||||
|
||||
fileMenu.add (rootItem);
|
||||
@ -87,6 +97,7 @@ public class MenuHandler
|
||||
+ " PRINT SPC(12):\n" + "NEXT :\n" + "VTAB 5:\n" + "HTAB 24:\n" + "PRINT AB$\n");
|
||||
|
||||
fileMenu.add (duplicateItem);
|
||||
fileMenu.add (debuggingItem);
|
||||
|
||||
formatMenu.add (lineWrapItem);
|
||||
formatMenu.add (showCatalogItem);
|
||||
@ -105,12 +116,21 @@ public class MenuHandler
|
||||
formatMenu.add (sector256Item);
|
||||
formatMenu.add (sector512Item);
|
||||
|
||||
formatMenu.addSeparator ();
|
||||
// set placeholders for the palettes
|
||||
List<Palette> palettes = HiResImage.getPalettes ();
|
||||
for (int i = 0; i < palettes.size (); i++)
|
||||
{
|
||||
JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem ("x");
|
||||
paletteGroup.add (menuItem);
|
||||
colourMenu.add (menuItem);
|
||||
}
|
||||
|
||||
formatMenu.add (colourQuirksItem);
|
||||
formatMenu.add (monochromeItem);
|
||||
formatMenu.add (debuggingItem);
|
||||
formatMenu.add (paletteItem);
|
||||
colourMenu.addSeparator ();
|
||||
colourMenu.add (colourQuirksItem);
|
||||
colourMenu.add (monochromeItem);
|
||||
colourMenu.addSeparator ();
|
||||
colourMenu.add (nextPaletteItem);
|
||||
colourMenu.add (prevPaletteItem);
|
||||
|
||||
helpMenu.add (new JMenuItem (new EnvironmentAction ()));
|
||||
|
||||
@ -184,6 +204,8 @@ public class MenuHandler
|
||||
prefs.putBoolean (PREFS_COLOUR_QUIRKS, colourQuirksItem.isSelected ());
|
||||
prefs.putBoolean (PREFS_MONOCHROME, monochromeItem.isSelected ());
|
||||
prefs.putBoolean (PREFS_DEBUGGING, debuggingItem.isSelected ());
|
||||
prefs.putInt (PREFS_PALETTE,
|
||||
HiResImage.getPaletteFactory ().getCurrentPaletteIndex ());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -197,6 +219,21 @@ public class MenuHandler
|
||||
monochromeItem.setSelected (prefs.getBoolean (PREFS_MONOCHROME, false));
|
||||
debuggingItem.setSelected (prefs.getBoolean (PREFS_DEBUGGING, false));
|
||||
|
||||
int paletteIndex = prefs.getInt (PREFS_PALETTE, 0);
|
||||
PaletteFactory paletteFactory = HiResImage.getPaletteFactory ();
|
||||
paletteFactory.setCurrentPalette (paletteIndex);
|
||||
Palette palette = paletteFactory.getCurrentPalette ();
|
||||
Enumeration<AbstractButton> enumeration = paletteGroup.getElements ();
|
||||
while (enumeration.hasMoreElements ())
|
||||
{
|
||||
JCheckBoxMenuItem item = (JCheckBoxMenuItem) enumeration.nextElement ();
|
||||
if (item.getText ().equals (palette.getName ()))
|
||||
{
|
||||
item.setSelected (true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
HiResImage.setDefaultColourQuirks (colourQuirksItem.isSelected ());
|
||||
HiResImage.setDefaultMonochrome (monochromeItem.isSelected ());
|
||||
VisicalcFile.setDefaultDebug (debuggingItem.isSelected ());
|
||||
|
45
src/com/bytezone/diskbrowser/gui/NextPaletteAction.java
Normal file
45
src/com/bytezone/diskbrowser/gui/NextPaletteAction.java
Normal file
@ -0,0 +1,45 @@
|
||||
package com.bytezone.diskbrowser.gui;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import com.bytezone.diskbrowser.applefile.Palette;
|
||||
import com.bytezone.diskbrowser.applefile.PaletteFactory.CycleDirection;
|
||||
|
||||
public class NextPaletteAction extends AbstractAction
|
||||
{
|
||||
private final DataPanel owner;
|
||||
private final ButtonGroup buttonGroup;
|
||||
|
||||
public NextPaletteAction (DataPanel owner, ButtonGroup buttonGroup)
|
||||
{
|
||||
super ("Next Palette");
|
||||
putValue (Action.SHORT_DESCRIPTION, "Select next color palette");
|
||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt N"));
|
||||
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_N);
|
||||
this.owner = owner;
|
||||
this.buttonGroup = buttonGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e)
|
||||
{
|
||||
Palette palette = owner.cyclePalette (CycleDirection.FORWARDS);
|
||||
if (palette != null)
|
||||
{
|
||||
Enumeration<AbstractButton> enumeration = buttonGroup.getElements ();
|
||||
while (enumeration.hasMoreElements ())
|
||||
{
|
||||
JCheckBoxMenuItem item = (JCheckBoxMenuItem) enumeration.nextElement ();
|
||||
if (item.getText ().equals (palette.getName ()))
|
||||
{
|
||||
item.setSelected (true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,28 +1,28 @@
|
||||
package com.bytezone.diskbrowser.gui;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import com.bytezone.diskbrowser.applefile.Palette;
|
||||
|
||||
public class PaletteAction extends AbstractAction
|
||||
{
|
||||
private final Palette palette;
|
||||
private final DataPanel owner;
|
||||
|
||||
public PaletteAction (DataPanel owner)
|
||||
public PaletteAction (DataPanel owner, Palette palette)
|
||||
{
|
||||
super ("Cycle Palette");
|
||||
putValue (Action.SHORT_DESCRIPTION, "Select next color palette");
|
||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt P"));
|
||||
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_P);
|
||||
super (palette.getName ());
|
||||
putValue (Action.SHORT_DESCRIPTION, "Select color palette: " + palette.getName ());
|
||||
this.owner = owner;
|
||||
this.palette = palette;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e)
|
||||
{
|
||||
owner.cyclePalette ();
|
||||
owner.selectPalette (palette);
|
||||
}
|
||||
}
|
45
src/com/bytezone/diskbrowser/gui/PreviousPaletteAction.java
Normal file
45
src/com/bytezone/diskbrowser/gui/PreviousPaletteAction.java
Normal file
@ -0,0 +1,45 @@
|
||||
package com.bytezone.diskbrowser.gui;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import com.bytezone.diskbrowser.applefile.Palette;
|
||||
import com.bytezone.diskbrowser.applefile.PaletteFactory.CycleDirection;
|
||||
|
||||
public class PreviousPaletteAction extends AbstractAction
|
||||
{
|
||||
private final DataPanel owner;
|
||||
private final ButtonGroup buttonGroup;
|
||||
|
||||
public PreviousPaletteAction (DataPanel owner, ButtonGroup buttonGroup)
|
||||
{
|
||||
super ("Previous Palette");
|
||||
putValue (Action.SHORT_DESCRIPTION, "Select previous color palette");
|
||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt P"));
|
||||
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_P);
|
||||
this.owner = owner;
|
||||
this.buttonGroup = buttonGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e)
|
||||
{
|
||||
Palette palette = owner.cyclePalette (CycleDirection.BACKWARDS);
|
||||
if (palette != null)
|
||||
{
|
||||
Enumeration<AbstractButton> enumeration = buttonGroup.getElements ();
|
||||
while (enumeration.hasMoreElements ())
|
||||
{
|
||||
JCheckBoxMenuItem item = (JCheckBoxMenuItem) enumeration.nextElement ();
|
||||
if (item.getText ().equals (palette.getName ()))
|
||||
{
|
||||
item.setSelected (true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user