content: /*
   * Marker_APP14.java    August 25, 2010, 23:27
   *
   * Copyright 2010, BinaryInternals.org. All rights reserved.
   * Use is subject to license terms.
   */
  package org.binaryinternals.format.jpeg;
  
  import java.io.IOException;
  import javax.swing.tree.DefaultMutableTreeNode;
  import org.binaryinternals.commonlib.core.FileFormatException;
  import org.binaryinternals.commonlib.core.PosDataInputStream;
  import org.binaryinternals.commonlib.ui.JTreeNodeFileComponent;
  
  /**
   *
   * @author Amos Shi
   */
  public class Marker_APP14 extends Marker {
  
      private String identifier;
  
      Marker_APP14(final PosDataInputStream pDIS, int marker_code) throws IOException, FileFormatException {
          super(pDIS, marker_code);
      }
  
      @Override
      protected void parse(final PosDataInputStream pDisMarker) throws IOException {
          super.parseInitSkip(pDisMarker);
          this.identifier = super.parseIdentifier(pDisMarker);
      }
  
      @Override
      public void generateTreeNode(DefaultMutableTreeNode parentNode) {
          DefaultMutableTreeNode markerNode = this.generateTreeNode_Marker(parentNode);
          int lastPos;
          JTreeNodeFileComponent comp;
          DefaultMutableTreeNode identifierNode;
  
          comp = new JTreeNodeFileComponent(
                  lastPos = this.getStartPos(),
                  2,
                  String.format("Marker code: 0x04X", this.marker_code));
          comp.setDescription(MarkerCode.getMarkerCodeDescription());
          markerNode.add(new DefaultMutableTreeNode(comp));
  
          comp = new JTreeNodeFileComponent(
                  lastPos = lastPos + 2,
                  2,
                  String.format("length: %d", this.getMarkerLength()));
          comp.setDescription(MarkerCode.getHeaderLengthDescription());
          markerNode.add(new DefaultMutableTreeNode(comp));
  
          markerNode.add(new DefaultMutableTreeNode(new JTreeNodeFileComponent(
                  lastPos = lastPos + 2,
                  this.identifier.length() + 1,
                  String.format("identifier: %s", this.identifier))));
          markerNode.add(identifierNode = new DefaultMutableTreeNode(new JTreeNodeFileComponent(
                  lastPos = lastPos + this.identifier.length() + 1,
                  this.startPos + this.length - lastPos,
                  this.identifier)));
      } // End of method generateTreeNode
  }
  