-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
333 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
CommonLib/src/main/java/org/freeinternals/commonlib/ui/binviewer/DataViewer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* JAsciiDataViewer.java September 08, 2019, 19:17 PM | ||
* | ||
* Copyright 2019, FreeInternals.org. All rights reserved. | ||
* Use is subject to license terms. | ||
*/ | ||
package org.freeinternals.commonlib.ui.binviewer; | ||
|
||
import javax.swing.JTextPane; | ||
|
||
/** | ||
* Display binary data. | ||
* | ||
* @author Amos Shi | ||
*/ | ||
public abstract class DataViewer extends JTextPane { | ||
|
||
/** | ||
* Binary data will be displayed. | ||
*/ | ||
private byte[] data = null; | ||
/** | ||
* Start index to be high-lighted. | ||
*/ | ||
private int selectedStartIndex = 0; | ||
/** | ||
* Length to be high-lighted. | ||
*/ | ||
private int selectedLength = 0; | ||
|
||
/** | ||
* Constructor. | ||
*/ | ||
public DataViewer() { | ||
super(); | ||
this.setEditable(false); | ||
this.setBorder(null); | ||
this.setContentType("text/html"); | ||
} | ||
|
||
/** | ||
* Set the binary data to be displayed. | ||
* | ||
* @param bin Binary data. | ||
*/ | ||
public void setData(final byte[] bin) { | ||
this.data = bin; | ||
this.updateContent(); | ||
} | ||
|
||
/** | ||
* Set the selection part to be high-lighted. | ||
* | ||
* @param startIndex Start index to be high-lighted | ||
* @param length Length to be high-lighted | ||
*/ | ||
public void setSelection(final int startIndex, final int length) { | ||
this.selectedStartIndex = startIndex; | ||
this.selectedLength = length; | ||
this.updateContent(); | ||
} | ||
|
||
/** | ||
* Return value of {@link #data}. | ||
* | ||
* @return Value of {@link #data} | ||
*/ | ||
protected byte[] getData() { | ||
return this.data; | ||
} | ||
|
||
/** | ||
* Return value of {@link #selectedStartIndex}. | ||
* | ||
* @return Value of {@link #selectedStartIndex} | ||
*/ | ||
protected int getSelectedStartIndex() { | ||
return this.selectedStartIndex; | ||
} | ||
|
||
/** | ||
* Return value of {@link #selectedLength}. | ||
* | ||
* @return Value of {@link #selectedLength} | ||
*/ | ||
protected int getSelectedLength() { | ||
return this.selectedLength; | ||
} | ||
|
||
protected abstract void updateContent(); | ||
} |
Oops, something went wrong.