IIOMetadataNode getNativeNode() {
   IIOMetadataNode node = new IIOMetadataNode("dqt");
   for (int i = 0; i < tables.size(); i++) {
     Qtable table = (Qtable) tables.get(i);
     node.appendChild(table.getNativeNode());
   }
   return node;
 }
 void print() {
   printTag("DQT");
   System.out.println("Num tables: " + Integer.toString(tables.size()));
   for (int i = 0; i < tables.size(); i++) {
     Qtable table = (Qtable) tables.get(i);
     table.print();
   }
   System.out.println();
 }
 protected Object clone() {
   DQTMarkerSegment newGuy = (DQTMarkerSegment) super.clone();
   newGuy.tables = new ArrayList(tables.size());
   Iterator iter = tables.iterator();
   while (iter.hasNext()) {
     Qtable table = (Qtable) iter.next();
     newGuy.tables.add(table.clone());
   }
   return newGuy;
 }
 protected Object clone() {
   Qtable newGuy = null;
   try {
     newGuy = (Qtable) super.clone();
   } catch (CloneNotSupportedException e) {
   } // won't happen
   if (data != null) {
     newGuy.data = (int[]) data.clone();
   }
   return newGuy;
 }
 /**
  * Assuming the given table was generated by scaling the "standard" visually lossless luminance
  * table, extract the scale factor that was used.
  */
 Qtable getChromaForLuma(Qtable luma) {
   Qtable newGuy = null;
   // Determine if the table is all the same values
   // if so, use the same table
   boolean allSame = true;
   for (int i = 1; i < luma.QTABLE_SIZE; i++) {
     if (luma.data[i] != luma.data[i - 1]) {
       allSame = false;
       break;
     }
   }
   if (allSame) {
     newGuy = (Qtable) luma.clone();
     newGuy.tableID = 1;
   } else {
     // Otherwise, find the largest coefficient less than 255.  This is
     // the largest value that we know did not clamp on scaling.
     int largestPos = 0;
     for (int i = 1; i < luma.QTABLE_SIZE; i++) {
       if (luma.data[i] > luma.data[largestPos]) {
         largestPos = i;
       }
     }
     // Compute the scale factor by dividing it by the value in the
     // same position from the "standard" table.
     // If the given table was not generated by scaling the standard,
     // the resulting table will still be reasonable, as it will reflect
     // a comparable scaling of chrominance frequency response of the
     // eye.
     float scaleFactor =
         ((float) (luma.data[largestPos]))
             / ((float) (JPEGQTable.K1Div2Luminance.getTable()[largestPos]));
     //    generate a new table
     JPEGQTable jpegTable = JPEGQTable.K2Div2Chrominance.getScaledInstance(scaleFactor, true);
     newGuy = new Qtable(jpegTable, 1);
   }
   return newGuy;
 }