mirror of
https://github.com/AppleCommander/AppleCommander.git
synced 2024-12-22 08:30:35 +00:00
Adding ability to view shape table files.
This commit is contained in:
parent
13be406278
commit
92147b03ac
@ -17,6 +17,7 @@ repositories {
|
||||
dependencies {
|
||||
implementation "net.sf.applecommander:ShrinkItArchive:$shkVersion"
|
||||
implementation "net.sf.applecommander:acdasm:$acdasmVersion"
|
||||
implementation "net.sf.applecommander:bastools-api:$btVersion"
|
||||
implementation "org.apache.commons:commons-csv:$commonsCsvVersion"
|
||||
implementation "com.google.code.gson:gson:$gsonVersion"
|
||||
|
||||
|
@ -0,0 +1,42 @@
|
||||
package com.webcodepro.applecommander.storage.filters;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
|
||||
import com.webcodepro.applecommander.storage.FileEntry;
|
||||
import com.webcodepro.applecommander.storage.FileFilter;
|
||||
|
||||
import io.github.applecommander.bastools.api.shapes.ShapeExporter;
|
||||
import io.github.applecommander.bastools.api.shapes.ShapeTable;
|
||||
|
||||
public class ShapeTableFileFilter implements FileFilter {
|
||||
@Override
|
||||
public byte[] filter(FileEntry fileEntry) {
|
||||
try {
|
||||
ShapeTable shapeTable = ShapeTable.read(fileEntry.getFileData());
|
||||
|
||||
ShapeExporter exporter = ShapeExporter.image()
|
||||
.border(true)
|
||||
.maxWidth(512)
|
||||
.png()
|
||||
.skipEmptyShapes(false)
|
||||
.build();
|
||||
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
exporter.export(shapeTable, outputStream);
|
||||
return outputStream.toByteArray();
|
||||
} catch (IOException ex) {
|
||||
throw new UncheckedIOException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSuggestedFileName(FileEntry fileEntry) {
|
||||
String fileName = fileEntry.getFilename().trim();
|
||||
if (!fileName.toLowerCase().endsWith(".png")) {
|
||||
fileName += ".png";
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
}
|
@ -353,6 +353,8 @@ FileViewerWindow.CopyTooltip=Copies selection to the clipboard (CTRL+C)
|
||||
FileViewerWindow.PrintTooltip=Print contents... (CTRL+P)
|
||||
FileViewerWindow.DisassemblyButton=Disassembly
|
||||
FileViewerWindow.DisassemblyTooltip=Displays file disassembled
|
||||
FileViewerWindow.ShapeTableButton=Shape Table
|
||||
FileViewerWindow.ShapeTableTooltip=Display as shape table
|
||||
|
||||
|
||||
# DiskWindow
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 364 B |
@ -51,10 +51,11 @@ import com.webcodepro.applecommander.storage.filters.AssemblySourceFileFilter;
|
||||
import com.webcodepro.applecommander.storage.filters.BusinessBASICFileFilter;
|
||||
import com.webcodepro.applecommander.storage.filters.DisassemblyFileFilter;
|
||||
import com.webcodepro.applecommander.storage.filters.GraphicsFileFilter;
|
||||
import com.webcodepro.applecommander.storage.filters.GutenbergFileFilter;
|
||||
import com.webcodepro.applecommander.storage.filters.IntegerBasicFileFilter;
|
||||
import com.webcodepro.applecommander.storage.filters.PascalTextFileFilter;
|
||||
import com.webcodepro.applecommander.storage.filters.ShapeTableFileFilter;
|
||||
import com.webcodepro.applecommander.storage.filters.TextFileFilter;
|
||||
import com.webcodepro.applecommander.storage.filters.GutenbergFileFilter;
|
||||
import com.webcodepro.applecommander.ui.UiBundle;
|
||||
import com.webcodepro.applecommander.ui.swt.filteradapter.ApplesoftFilterAdapter;
|
||||
import com.webcodepro.applecommander.ui.swt.filteradapter.BusinessBASICFilterAdapter;
|
||||
@ -63,6 +64,7 @@ import com.webcodepro.applecommander.ui.swt.filteradapter.FilterAdapter;
|
||||
import com.webcodepro.applecommander.ui.swt.filteradapter.GraphicsFilterAdapter;
|
||||
import com.webcodepro.applecommander.ui.swt.filteradapter.HexFilterAdapter;
|
||||
import com.webcodepro.applecommander.ui.swt.filteradapter.RawDumpFilterAdapter;
|
||||
import com.webcodepro.applecommander.ui.swt.filteradapter.ShapeTableFilterAdapter;
|
||||
import com.webcodepro.applecommander.ui.swt.filteradapter.TextFilterAdapter;
|
||||
import com.webcodepro.applecommander.ui.swt.util.ImageManager;
|
||||
import com.webcodepro.applecommander.ui.swt.util.SwtUtil;
|
||||
@ -93,9 +95,11 @@ public class FileViewerWindow {
|
||||
private ToolBar toolBar;
|
||||
private ToolItem nativeToolItem;
|
||||
private ToolItem hexDumpToolItem;
|
||||
private Optional<ToolItem> disassemblyToolItem = Optional.empty(); // May or may not be setup
|
||||
private ToolItem rawDumpToolItem;
|
||||
private ToolItem copyToolItem;
|
||||
// May or may not be setup
|
||||
private Optional<ToolItem> disassemblyToolItem = Optional.empty();
|
||||
private Optional<ToolItem> shapeTableToolItem = Optional.empty();
|
||||
|
||||
private Font courier;
|
||||
private Color black;
|
||||
@ -108,6 +112,7 @@ public class FileViewerWindow {
|
||||
private FilterAdapter hexFilterAdapter;
|
||||
private FilterAdapter rawDumpFilterAdapter;
|
||||
private FilterAdapter disassemblyFilterAdapter;
|
||||
private FilterAdapter shapeTableFilterAdapter;
|
||||
|
||||
/**
|
||||
* Construct the file viewer window.
|
||||
@ -232,6 +237,11 @@ public class FileViewerWindow {
|
||||
textBundle.get("FileViewerWindow.DisassemblyTooltip"),
|
||||
imageManager.get(ImageManager.ICON_COMPILE_FILE)
|
||||
));
|
||||
nativeFilterAdapterMap.put(ShapeTableFileFilter.class,
|
||||
new ShapeTableFilterAdapter(this, textBundle.get("FileViewerWindow.ShapeTableButton"),
|
||||
textBundle.get("FileViewerWindow.ShapeTableTooltip"),
|
||||
imageManager.get(ImageManager.ICON_SHAPE_TABLE)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -274,6 +284,7 @@ public class FileViewerWindow {
|
||||
// Add the disassembly button only if it's not the default and if this filetype has a start address.
|
||||
if (fileEntry != null && fileEntry.needsAddress() && !(nativeFilter instanceof DisassemblyFileFilter)) {
|
||||
disassemblyToolItem = Optional.of(createDisassemblyToolItem());
|
||||
shapeTableToolItem = Optional.of(createShapeTableToolItem());
|
||||
}
|
||||
new ToolItem(toolBar, SWT.SEPARATOR);
|
||||
copyToolItem = createCopyToolItem();
|
||||
@ -318,6 +329,18 @@ public class FileViewerWindow {
|
||||
return toolItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the shape table tool item (button).
|
||||
*/
|
||||
protected ToolItem createShapeTableToolItem() {
|
||||
shapeTableFilterAdapter = new ShapeTableFilterAdapter(this, textBundle.get("FileViewerWindow.ShapeTableButton"),
|
||||
textBundle.get("FileViewerWindow.ShapeTableTooltip"),
|
||||
imageManager.get(ImageManager.ICON_SHAPE_TABLE));
|
||||
shapeTableFilterAdapter.setShapeTableSelected();
|
||||
ToolItem toolItem = shapeTableFilterAdapter.create(toolBar);
|
||||
return toolItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the copy tool item (button).
|
||||
*/
|
||||
@ -377,15 +400,15 @@ public class FileViewerWindow {
|
||||
switch (event.keyCode) {
|
||||
case SWT.F2: // the "native" file format (image, text, etc)
|
||||
getNativeFilterAdapter().display();
|
||||
setFilterToolItemSelection(true, false, false, false);
|
||||
setFilterToolItemSelection(true, false, false, false, false);
|
||||
break;
|
||||
case SWT.F3: // Hex format
|
||||
getHexFilterAdapter().display();
|
||||
setFilterToolItemSelection(false, true, false, false);
|
||||
setFilterToolItemSelection(false, true, false, false, false);
|
||||
break;
|
||||
case SWT.F4: // "Raw" hex format
|
||||
getRawDumpFilterAdapter().display();
|
||||
setFilterToolItemSelection(false, false, true, false);
|
||||
setFilterToolItemSelection(false, false, true, false, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -421,11 +444,13 @@ public class FileViewerWindow {
|
||||
public Color getBlueColor() {
|
||||
return blue;
|
||||
}
|
||||
public void setFilterToolItemSelection(boolean nativeSelected, boolean hexSelected, boolean dumpSelected, boolean disassemblySelected) {
|
||||
public void setFilterToolItemSelection(boolean nativeSelected, boolean hexSelected, boolean dumpSelected,
|
||||
boolean disassemblySelected, boolean shapeTableSelected) {
|
||||
if (nativeToolItem != null) nativeToolItem.setSelection(nativeSelected);
|
||||
hexDumpToolItem.setSelection(hexSelected);
|
||||
rawDumpToolItem.setSelection(dumpSelected);
|
||||
disassemblyToolItem.ifPresent(toolItem -> toolItem.setSelection(disassemblySelected));
|
||||
shapeTableToolItem.ifPresent(toolItem -> toolItem.setSelection(shapeTableSelected));
|
||||
}
|
||||
protected ContentTypeAdapter getContentTypeAdapter() {
|
||||
return contentTypeAdapter;
|
||||
|
@ -51,6 +51,7 @@ public abstract class FilterAdapter {
|
||||
private boolean hexSelected = false;
|
||||
private boolean dumpSelected = false;
|
||||
private boolean disassemblySelected = false;
|
||||
private boolean shapeTableSelected = false;
|
||||
|
||||
public FilterAdapter(FileViewerWindow window, String text, String toolTipText,
|
||||
Image image) {
|
||||
@ -78,7 +79,8 @@ public abstract class FilterAdapter {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
display();
|
||||
getWindow().setFilterToolItemSelection(
|
||||
isNativeSelected(), isHexSelected(), isDumpSelected(), isDisassemblySelected());
|
||||
isNativeSelected(), isHexSelected(), isDumpSelected(), isDisassemblySelected(),
|
||||
isShapeTableSelected());
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -132,25 +134,36 @@ public abstract class FilterAdapter {
|
||||
hexSelected = false;
|
||||
dumpSelected = true;
|
||||
disassemblySelected = false;
|
||||
shapeTableSelected = false;
|
||||
}
|
||||
public void setHexSelected() {
|
||||
nativeSelected = false;
|
||||
hexSelected = true;
|
||||
dumpSelected = false;
|
||||
disassemblySelected = false;
|
||||
shapeTableSelected = false;
|
||||
}
|
||||
public void setDisassemblySelected() {
|
||||
nativeSelected = false;
|
||||
hexSelected = false;
|
||||
dumpSelected = false;
|
||||
disassemblySelected = true;
|
||||
shapeTableSelected = false;
|
||||
}
|
||||
public void setNativeSelected() {
|
||||
nativeSelected = true;
|
||||
hexSelected = false;
|
||||
dumpSelected = false;
|
||||
disassemblySelected = false;
|
||||
shapeTableSelected = false;
|
||||
}
|
||||
public void setShapeTableSelected() {
|
||||
nativeSelected = false;
|
||||
hexSelected = false;
|
||||
dumpSelected = false;
|
||||
disassemblySelected = false;
|
||||
shapeTableSelected = true;
|
||||
}
|
||||
protected boolean isDumpSelected() {
|
||||
return dumpSelected;
|
||||
}
|
||||
@ -163,6 +176,9 @@ public abstract class FilterAdapter {
|
||||
protected boolean isNativeSelected() {
|
||||
return nativeSelected;
|
||||
}
|
||||
protected boolean isShapeTableSelected() {
|
||||
return shapeTableSelected;
|
||||
}
|
||||
protected FileViewerWindow getWindow() {
|
||||
return window;
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
package com.webcodepro.applecommander.ui.swt.filteradapter;
|
||||
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
|
||||
import com.webcodepro.applecommander.storage.FileFilter;
|
||||
import com.webcodepro.applecommander.storage.filters.ShapeTableFileFilter;
|
||||
import com.webcodepro.applecommander.ui.swt.FileViewerWindow;
|
||||
|
||||
public class ShapeTableFilterAdapter extends GraphicsFilterAdapter {
|
||||
public ShapeTableFilterAdapter(FileViewerWindow window, String text, String toolTipText, Image image) {
|
||||
super(window, text, toolTipText, image);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FileFilter getFileFilter() {
|
||||
return new ShapeTableFileFilter();
|
||||
}
|
||||
}
|
@ -67,6 +67,7 @@ public class ImageManager {
|
||||
public static final String ICON_COPY = "copy.gif"; //$NON-NLS-1$
|
||||
public static final String ICON_COMPARE_DISKS = "comparedisks.gif"; //$NON-NLS-1$
|
||||
public static final String ICON_CHANGE_IMAGE_ORDER = "changeorder.gif"; //$NON-NLS-1$
|
||||
public static final String ICON_SHAPE_TABLE = "shape_table.gif";
|
||||
|
||||
public static final String LOGO_EXPORT_WIZARD = "ExportWizardLogo.jpg"; //$NON-NLS-1$
|
||||
public static final String LOGO_APPLECOMMANDER = "AppleCommanderLogo.jpg"; //$NON-NLS-1$
|
||||
@ -91,7 +92,7 @@ public class ImageManager {
|
||||
ICON_VIEW_AS_SPREADSHEET, ICON_VIEW_AS_TEXTFILE,
|
||||
ICON_VIEW_AS_WORDPROCESSOR, ICON_VIEW_AS_BASIC_PROGRAM,
|
||||
ICON_COPY, ICON_COMPARE_DISKS,
|
||||
ICON_CHANGE_IMAGE_ORDER,
|
||||
ICON_CHANGE_IMAGE_ORDER, ICON_SHAPE_TABLE,
|
||||
// Logos:
|
||||
LOGO_EXPORT_WIZARD, LOGO_APPLECOMMANDER,
|
||||
LOGO_DISK_IMAGE_WIZARD, LOGO_IMPORT_WIZARD,
|
||||
|
Loading…
Reference in New Issue
Block a user