[Japi-cvs] SF.net SVN: japi:[644] progs
Status: Beta
Brought to you by:
christianhujer
|
From: <chr...@us...> - 2008-10-06 12:41:04
|
Revision: 644
http://japi.svn.sourceforge.net/japi/?rev=644&view=rev
Author: christianhujer
Date: 2008-10-06 12:40:15 +0000 (Mon, 06 Oct 2008)
Log Message:
-----------
Added module for jhexview prototype.
Added Paths:
-----------
progs/jhexview/
progs/jhexview/branches/
progs/jhexview/tags/
progs/jhexview/trunk/
progs/jhexview/trunk/jhexview.iml
progs/jhexview/trunk/src/
progs/jhexview/trunk/src/doc/
progs/jhexview/trunk/src/prj/
progs/jhexview/trunk/src/prj/net/
progs/jhexview/trunk/src/prj/net/sf/
progs/jhexview/trunk/src/prj/net/sf/japi/
progs/jhexview/trunk/src/prj/net/sf/japi/progs/
progs/jhexview/trunk/src/prj/net/sf/japi/progs/jhexview/
progs/jhexview/trunk/src/prj/net/sf/japi/progs/jhexview/HexViewPane.java
progs/jhexview/trunk/src/prj/net/sf/japi/progs/jhexview/JHexViewApplication.java
progs/jhexview/trunk/src/prj/net/sf/japi/progs/jhexview/action.properties
progs/jhexview/trunk/src/tst/
Added: progs/jhexview/trunk/jhexview.iml
===================================================================
--- progs/jhexview/trunk/jhexview.iml (rev 0)
+++ progs/jhexview/trunk/jhexview.iml 2008-10-06 12:40:15 UTC (rev 644)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module relativePaths="true" type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src/doc" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/prj" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/tst" isTestSource="true" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="library" name="annotations" level="project" />
+ <orderEntry type="library" name="junit" level="project" />
+ <orderEntry type="module" module-name="libs-argparser" />
+ <orderEntry type="module" module-name="libs-swing-app" />
+ <orderEntryProperties />
+ </component>
+</module>
+
Property changes on: progs/jhexview/trunk/jhexview.iml
___________________________________________________________________
Added: svn:mime-type
+ text/xml
Added: svn:eol-style
+ LF
Added: progs/jhexview/trunk/src/prj/net/sf/japi/progs/jhexview/HexViewPane.java
===================================================================
--- progs/jhexview/trunk/src/prj/net/sf/japi/progs/jhexview/HexViewPane.java (rev 0)
+++ progs/jhexview/trunk/src/prj/net/sf/japi/progs/jhexview/HexViewPane.java 2008-10-06 12:40:15 UTC (rev 644)
@@ -0,0 +1,66 @@
+package net.sf.japi.progs.jhexview;
+
+import java.awt.BorderLayout;
+import java.util.Formatter;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+
+/** Component for viewing binary data.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class HexViewPane extends JPanel {
+
+
+ /** The data to show. */
+ private byte[] data;
+
+ /** The columns to show. */
+ private int cols = 16;
+
+ /** The rows to show. */
+ private int rows;
+
+ /** The TextArea that displays the hex info. */
+ private JTextArea textArea = new JTextArea(25, cols * 4 + 8);
+
+ /** Creates a HexViewPane.
+ * The data is referenced, not copied.
+ * Changes to the array will write through to the HexViewPane and vice versa.
+ * @param data Data to view.
+ */
+ public HexViewPane(final byte[] data) {
+ setLayout(new BorderLayout());
+ textArea.setEditable(false);
+ add(new JScrollPane(textArea));
+ this.data = data;
+ rows = (data.length + cols - 1) / cols;
+ updateData();
+ }
+
+ /** Updates the data. */
+ private void updateData() {
+ final Formatter format = new Formatter();
+ for (int i = 0; i < rows; i++) {
+ format.format("%08x ", i * cols);
+ for (int j = 0; j < cols; j++) {
+ final int offset = i * cols + j;
+ if (offset < data.length) {
+ format.format("%02x ", data[offset]);
+ } else {
+ format.format(" ");
+ }
+ }
+ for (int j = 0; j < cols; j++) {
+ final int offset = i * cols + j;
+ if (offset < data.length) {
+ format.format(" %c", (char) data[offset]);
+ } else {
+ format.format(" ");
+ }
+ }
+ format.format("\n");
+ }
+ textArea.setText(format.toString());
+ }
+}
Property changes on: progs/jhexview/trunk/src/prj/net/sf/japi/progs/jhexview/HexViewPane.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ LF
Added: progs/jhexview/trunk/src/prj/net/sf/japi/progs/jhexview/JHexViewApplication.java
===================================================================
--- progs/jhexview/trunk/src/prj/net/sf/japi/progs/jhexview/JHexViewApplication.java (rev 0)
+++ progs/jhexview/trunk/src/prj/net/sf/japi/progs/jhexview/JHexViewApplication.java 2008-10-06 12:40:15 UTC (rev 644)
@@ -0,0 +1,42 @@
+package net.sf.japi.progs.jhexview;
+
+import net.sf.japi.io.args.ArgParser;
+import net.sf.japi.swing.app.AppLaunchCommand;
+import net.sf.japi.swing.app.Application;
+import net.sf.japi.swing.app.Document;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * TODO
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class JHexViewApplication extends Application<byte[]> {
+
+ /** Main program.
+ * @param args Command line arguments (try --help).
+ */
+ public static void main(final String... args) {
+ ArgParser.simpleParseAndRun(new AppLaunchCommand(JHexViewApplication.class), args);
+ }
+
+ /** Creates a JHexViewApplication. */
+ public JHexViewApplication() {
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void save(@NotNull final Document<byte[]> doc, @NotNull final String uri) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ // TODO
+ }
+
+ public Document<byte[]> createNew() {
+ return null;//To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ /** {@inheritDoc} */
+ @NotNull
+ public Document<byte[]> load(@NotNull final String uri) {
+ throw new UnsupportedOperationException();
+ }
+}
Property changes on: progs/jhexview/trunk/src/prj/net/sf/japi/progs/jhexview/JHexViewApplication.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ LF
Added: progs/jhexview/trunk/src/prj/net/sf/japi/progs/jhexview/action.properties
===================================================================
--- progs/jhexview/trunk/src/prj/net/sf/japi/progs/jhexview/action.properties (rev 0)
+++ progs/jhexview/trunk/src/prj/net/sf/japi/progs/jhexview/action.properties 2008-10-06 12:40:15 UTC (rev 644)
@@ -0,0 +1 @@
+application.title=JHexView
Property changes on: progs/jhexview/trunk/src/prj/net/sf/japi/progs/jhexview/action.properties
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ LF
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|