added some documentation

This commit is contained in:
hneemann 2016-04-10 14:10:15 +02:00
parent 4506c2cdb5
commit 5422cad06e
3 changed files with 32 additions and 0 deletions

View File

@ -6,12 +6,21 @@ import java.util.ArrayList;
import java.util.HashMap;
/**
* Represents a ROM listing
*
* @author hneemann
*/
public class Listing implements javax.swing.ListModel<String> {
private final ArrayList<String> lines;
private final HashMap<Integer, Integer> addrMap;
/**
* Creates a new instance.
* The given file is read.
*
* @param filename the filename
* @throws IOException IOException
*/
public Listing(File filename) throws IOException {
lines = new ArrayList<String>();
addrMap = new HashMap<>();
@ -55,6 +64,12 @@ public class Listing implements javax.swing.ListModel<String> {
public void removeListDataListener(ListDataListener l) {
}
/**
* returns the line belonging to the given address
*
* @param addr the address
* @return the line or null if not found.
*/
public Integer getLine(int addr) {
return addrMap.get(addr);
}

View File

@ -10,6 +10,9 @@ import java.io.File;
import java.io.IOException;
/**
* The dialog to show the ROM listing while running.
* Used to debug assembler code.
*
* @author hneemann
*/
public class ROMListingDialog extends JDialog implements Observer {
@ -19,6 +22,13 @@ public class ROMListingDialog extends JDialog implements Observer {
private final JList<String> list;
private int lastAddr = -1;
/**
* Creates a new instance
*
* @param parent the parent frame
* @param rom the rom element
* @throws IOException IOException
*/
public ROMListingDialog(JFrame parent, ROM rom) throws IOException {
super(parent, Lang.get("win_listing"), false);
this.rom = rom;
@ -36,6 +46,7 @@ public class ROMListingDialog extends JDialog implements Observer {
listing = new Listing(filename);
list = new JList<>(listing);
list.setFont(new Font("monospaced", Font.PLAIN, 12));
list.setVisibleRowCount(30);
rom.getAddrIn().addObserver(this);
hasChanged();

View File

@ -0,0 +1,6 @@
/**
* Contains the classes to hold and show a ROM-Listing
*
* @author hneemann
*/
package de.neemann.digital.gui.components.listing;