private String buildSummary() {
   final String tmp;
   if (range.getPeriod() == Period.TOUT) {
     final String startDate =
         I18N.createDateAndTimeFormat().format(collector.getCounters().get(0).getStartDate());
     tmp =
         getFormattedString(
             "Statistiques",
             "JavaMelody",
             I18N.getCurrentDateAndTime(),
             startDate,
             collector.getApplication());
   } else {
     tmp =
         getFormattedString(
             "Statistiques_sans_depuis",
             "JavaMelody",
             I18N.getCurrentDateAndTime(),
             collector.getApplication());
   }
   if (javaInformationsList.get(0).getContextDisplayName() != null) {
     return tmp + " (" + javaInformationsList.get(0).getContextDisplayName() + ')';
   }
   return tmp;
 }
Exemple #2
0
  private void initGraphPeriodAndSize(Range range, int width, int height, RrdGraphDef graphDef) {
    // ending timestamp is the (current) timestamp in seconds
    // starting timestamp will be adjusted for each graph
    final long endTime;
    final long startTime;
    if (range.getPeriod() == null) {
      // si endDate à la date du jour, alors on ne dépasse pas l'heure courante
      endTime = Math.min(range.getEndDate().getTime() / 1000, Util.getTime());
      startTime = range.getStartDate().getTime() / 1000;
    } else {
      endTime = Util.getTime();
      startTime = endTime - range.getPeriod().getDurationSeconds();
    }
    final String label = getLabel();
    final String titleStart;
    if (label.length() > 31 && width <= 200) {
      // si le label est trop long, on raccourci le titre sinon il ne rentre pas
      titleStart = label;
    } else {
      titleStart = label + " - " + range.getLabel();
    }
    final String titleEnd;
    if (width > 400) {
      if (range.getPeriod() == null) {
        titleEnd = " - " + I18N.getFormattedString("sur", getApplication());
      } else {
        titleEnd =
            " - " + I18N.getCurrentDate() + ' ' + I18N.getFormattedString("sur", getApplication());
      }
    } else {
      titleEnd = "";
      if (range.getPeriod() == null) {
        // si période entre 2 dates et si pas de zoom,
        // alors on réduit de 2 point la fonte du titre pour qu'il rentre dans le cadre
        graphDef.setLargeFont(
            graphDef.getLargeFont().deriveFont(graphDef.getLargeFont().getSize2D() - 2f));
      }
    }
    graphDef.setStartTime(startTime);
    graphDef.setEndTime(endTime);
    graphDef.setTitle(titleStart + titleEnd);
    graphDef.setFirstDayOfWeek(Calendar.getInstance(I18N.getCurrentLocale()).getFirstDayOfWeek());
    // or if the user locale patch is merged we should do:
    // (https://sourceforge.net/tracker/?func=detail&aid=3403733&group_id=82668&atid=566807)
    // graphDef.setLocale(I18N.getCurrentLocale());

    // rq : la largeur et la hauteur de l'image sont plus grandes que celles fournies
    // car jrobin ajoute la largeur et la hauteur des textes et autres
    graphDef.setWidth(width);
    graphDef.setHeight(height);
    if (width <= 100) {
      graphDef.setNoLegend(true);
      graphDef.setUnitsLength(0);
      graphDef.setShowSignature(false);
      graphDef.setTitle(null);
    }
    //		graphDef.setColor(RrdGraphConstants.COLOR_BACK, new GradientPaint(0, 0,
    //				RrdGraphConstants.DEFAULT_BACK_COLOR.brighter(), 0, height,
    //				RrdGraphConstants.DEFAULT_BACK_COLOR));
  }
Exemple #3
0
 String getLabel() {
   if (requestName == null) {
     // c'est un jrobin global issu soit de JavaInformations soit d'un Counter dans le Collector
     return I18N.getString(getName());
   }
   // c'est un jrobin issu d'un CounterRequest dans le Collector
   final String shortRequestName = requestName.substring(0, Math.min(30, requestName.length()));
   // plus nécessaire:  if (getName().startsWith("error")) {
   // c'est un jrobin issu d'un CounterRequest du Counter "error"
   // return I18N.getString("Erreurs_par_minute_pour") + ' ' + shortRequestName; }
   return I18N.getFormattedString("Temps_moyens_de", shortRequestName);
 }
Exemple #4
0
  byte[] graph(Range range, int width, int height, boolean maxHidden) throws IOException {
    // static init of the AppContext ClassLoader
    AppContextClassLoaderLeakPrevention.dummy();

    try {
      // Rq : il pourrait être envisagé de récupérer les données dans les fichiers rrd ou autre
      // stockage
      // puis de faire des courbes en sparklines html (sauvegardées dans la page html)
      // ou avec http://code.google.com/apis/chart/types.html#sparkline ou jfreechart

      // create common part of graph definition
      final RrdGraphDef graphDef = new RrdGraphDef();
      if (Locale.CHINESE.getLanguage().equals(I18N.getResourceBundle().getLocale().getLanguage())) {
        graphDef.setSmallFont(new Font(Font.MONOSPACED, Font.PLAIN, 10));
        graphDef.setLargeFont(new Font(Font.MONOSPACED, Font.BOLD, 12));
      }

      initGraphSource(graphDef, height, maxHidden);

      initGraphPeriodAndSize(range, width, height, graphDef);

      graphDef.setImageFormat("png");
      graphDef.setFilename("-");
      // il faut utiliser le pool pour les performances
      // et pour éviter des erreurs d'accès concurrents sur les fichiers
      // entre différentes générations de graphs et aussi avec l'écriture des données
      graphDef.setPoolUsed(true);
      return new RrdGraph(graphDef).getRrdGraphInfo().getBytes();
    } catch (final RrdException e) {
      throw createIOException(e);
    }
  }
  private void savePrefs() {
    SikuliIDE ide = SikuliIDE.getInstance();
    pref.setCaptureDelay((Double) _spnDelay.getValue());
    pref.setCaptureHotkey(_cap_hkey);
    pref.setCaptureHotkeyModifiers(_cap_mod);
    pref.setAutoNamingMethod(
        _radTimestamp.isSelected()
            ? UserPreferences.AUTO_NAMING_TIMESTAMP
            : _radOCR.isSelected()
                ? UserPreferences.AUTO_NAMING_OCR
                : UserPreferences.AUTO_NAMING_OFF);
    if (_old_cap_hkey != _cap_hkey || _old_cap_mod != _cap_mod) {
      ide.removeCaptureHotkey(_old_cap_hkey, _old_cap_mod);
      ide.installCaptureHotkey(_cap_hkey, _cap_mod);
    }
    pref.setCheckUpdate(_chkAutoUpdate.isSelected());

    pref.setExpandTab(_chkExpandTab.isSelected());
    pref.setTabWidth((Integer) _spnTabWidth.getValue());

    pref.setFontName((String) _cmbFontName.getSelectedItem());
    pref.setFontSize((Integer) _spnFontSize.getValue());

    Locale locale = (Locale) _cmbLang.getSelectedItem();
    pref.setLocale(locale);
    I18N.setLocale(locale);
  }
Exemple #6
0
  public SampleModel getSampleModel() {
    if (sampleModel != null) return sampleModel;

    int realWidth = (int) Math.min(tileWidth, width);
    int realHeight = (int) Math.min(tileHeight, height);

    if (nComp == 1 && (maxDepth == 1 || maxDepth == 2 || maxDepth == 4))
      sampleModel =
          new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE, realWidth, realHeight, maxDepth);
    else if (maxDepth <= 8)
      sampleModel =
          new PixelInterleavedSampleModel(
              DataBuffer.TYPE_BYTE, realWidth, realHeight, nComp, realWidth * nComp, bandOffsets);
    else if (maxDepth <= 16)
      sampleModel =
          new PixelInterleavedSampleModel(
              isSigned ? DataBuffer.TYPE_SHORT : DataBuffer.TYPE_USHORT,
              realWidth,
              realHeight,
              nComp,
              realWidth * nComp,
              bandOffsets);
    else if (maxDepth <= 32)
      sampleModel =
          new PixelInterleavedSampleModel(
              DataBuffer.TYPE_INT, realWidth, realHeight, nComp, realWidth * nComp, bandOffsets);
    else throw new IllegalArgumentException(I18N.getString("J2KReadState11") + " " + +maxDepth);
    return sampleModel;
  }
    @Override
    public Component getComponent() {
      JPanel glob = new JPanel(new MigLayout("wrap 1"));

      // Update only a local preview until the changes are applied.
      // About #497
      CanvasSE localPreview = new CanvasSE(usp.getSymbolizer());

      glob.add(new LinePanel(usp, localPreview, I18N.tr(BORDER_SETTINGS), true, true));

      glob.add(new AreaPanel(usp, localPreview, I18N.tr(FILL_SETTINGS), true));

      glob.add(new PreviewPanel(localPreview));

      return glob;
    }
Exemple #8
0
    @Override
    public void layerRemoved(LayerCollectionEvent e) {
      HashSet<ILayer> newSelection = new HashSet<ILayer>();
      newSelection.addAll(Arrays.asList(selectedLayers));
      ILayer[] affected = e.getAffected();
      for (final ILayer layer : affected) {
        // Check active
        if (activeLayer == layer) {
          setActiveLayer(null);
        }

        // Check selection
        newSelection.remove(layer);
        layer.removeLayerListenerRecursively(openerListener);
        if (isOpen()) {
          try {
            layer.close();
          } catch (LayerException e1) {
            LOGGER.warn(I18N.tr("Cannot close layer {0}", layer.getName()), e1);
          }
        }
      }

      setSelectedLayers(newSelection.toArray(new ILayer[newSelection.size()]));
      // checkIfHasToResetSRID();
    }
 private void checkSampleModel(SampleModel sm) {
   int type = sm.getDataType();
   if (type < DataBuffer.TYPE_BYTE
       || type > DataBuffer.TYPE_INT
       || sm.getNumBands() != 1
       || sm.getSampleSize(0) != 1)
     throw new IllegalArgumentException(I18N.getString("WBMPImageWriter2"));
 }
 public void setOutput(Object output) {
   super.setOutput(output); // validates output
   if (output != null) {
     if (!(output instanceof ImageOutputStream))
       throw new IllegalArgumentException(I18N.getString("WBMPImageWriter"));
     this.stream = (ImageOutputStream) output;
   } else this.stream = null;
 }
  private int getTileNum(int x, int y) {
    int num = (y - getMinTileY()) * getNumXTiles() + x - getMinTileX();

    if (num < 0 || num >= getNumXTiles() * getNumYTiles())
      throw new IllegalArgumentException(I18N.getString("RawRenderedImage0"));

    return num;
  }
  public synchronized Raster getTile(int tileX, int tileY) {
    if (currentTile != null && currentTileGrid.x == tileX && currentTileGrid.y == tileY)
      return currentTile;

    if (tileX >= getNumXTiles() || tileY >= getNumYTiles())
      throw new IllegalArgumentException(I18N.getString("RawRenderedImage0"));

    try {
      iis.seek(position + (tileY * originalNumXTiles + tileX) * tileDataSize);

      int x = tileXToX(tileX);
      int y = tileYToY(tileY);
      currentTile = Raster.createWritableRaster(sampleModel, new Point(x, y));

      if (noTransform) {
        switch (sampleModel.getDataType()) {
          case DataBuffer.TYPE_BYTE:
            byte[][] buf = ((DataBufferByte) currentTile.getDataBuffer()).getBankData();
            for (int i = 0; i < buf.length; i++) iis.readFully(buf[i], 0, buf[i].length);
            break;

          case DataBuffer.TYPE_SHORT:
            short[][] sbuf = ((DataBufferShort) currentTile.getDataBuffer()).getBankData();
            for (int i = 0; i < sbuf.length; i++) iis.readFully(sbuf[i], 0, sbuf[i].length);
            break;

          case DataBuffer.TYPE_USHORT:
            short[][] usbuf = ((DataBufferUShort) currentTile.getDataBuffer()).getBankData();
            for (int i = 0; i < usbuf.length; i++) iis.readFully(usbuf[i], 0, usbuf[i].length);
            break;
          case DataBuffer.TYPE_INT:
            int[][] ibuf = ((DataBufferInt) currentTile.getDataBuffer()).getBankData();
            for (int i = 0; i < ibuf.length; i++) iis.readFully(ibuf[i], 0, ibuf[i].length);
            break;
          case DataBuffer.TYPE_FLOAT:
            float[][] fbuf = ((DataBufferFloat) currentTile.getDataBuffer()).getBankData();
            for (int i = 0; i < fbuf.length; i++) iis.readFully(fbuf[i], 0, fbuf[i].length);
            break;
          case DataBuffer.TYPE_DOUBLE:
            double[][] dbuf = ((DataBufferDouble) currentTile.getDataBuffer()).getBankData();
            for (int i = 0; i < dbuf.length; i++) iis.readFully(dbuf[i], 0, dbuf[i].length);
            break;
        }
      } else {
        currentTile = readSubsampledRaster((WritableRaster) currentTile);
      }
    } catch (IOException e) {
      throw new RuntimeException(e);
    }

    if (currentTileGrid == null) currentTileGrid = new Point(tileX, tileY);
    else {
      currentTileGrid.x = tileX;
      currentTileGrid.y = tileY;
    }

    return currentTile;
  }
public class PasswordDialog extends JDialog {
  private static final long serialVersionUID = 1L;
  JPanel panel = new JPanel();
  JPasswordField password = new JPasswordField(1);
  JLabel passLabel = new JLabel(I18N.getLocaleString("PASSWORD_PASSLABEL"));
  JButton submitButton = new JButton(I18N.getLocaleString("MAIN_SUBMIT"));

  public PasswordDialog(LaunchFrame instance, boolean modal) {
    super(instance, modal);

    setIconImage(
        Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/image/logo_ftb.png")));
    setTitle(I18N.getLocaleString("PASSWORD_TITLE"));
    setBounds(300, 300, 300, 120);
    setResizable(false);

    getRootPane().setDefaultButton(submitButton);

    panel.setBounds(0, 0, 300, 100);
    setContentPane(panel);
    panel.setLayout(null);

    passLabel.setBounds(10, 10, 80, 30);
    passLabel.setVisible(true);
    panel.add(passLabel);

    password.setBounds(100, 10, 170, 30);
    password.setVisible(true);
    panel.add(password);

    submitButton.setBounds(105, 50, 90, 25);
    submitButton.setVisible(true);
    submitButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            if (!new String(password.getPassword()).isEmpty()) {
              LaunchFrame.tempPass = new String(password.getPassword());
              setVisible(false);
            }
          }
        });
    panel.add(submitButton);
  }
}
Exemple #14
0
  /**
   * Constructs <code>J2KReadState</code>.
   *
   * @param iis The input stream.
   * @param param The reading parameters.
   * @param reader The <code>J2KImageReader</code> which holds this state. It is necessary for
   *     processing abortion.
   * @throw IllegalArgumentException If the provided <code>iis</code>, or <code>param</code> is
   *     <code>null</code>.
   */
  public J2KReadState(ImageInputStream iis, J2KImageReadParamJava param, J2KImageReader reader) {
    if (iis == null || param == null)
      throw new IllegalArgumentException(I18N.getString("J2KReadState0"));

    this.iis = iis;
    this.j2krparam = param;
    this.reader = reader;
    initializeRead(0, param, null);
  }
Exemple #15
0
 private void jbInit() throws Exception {
   jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
   jLabel1.setText(I18N.getMessageString("Initializing ..."));
   setLayout(borderLayout1);
   this.setDefaultCloseOperation(3);
   setResizable(false);
   setTitle("synPOS");
   add(jLabel1, java.awt.BorderLayout.CENTER);
 }
Exemple #16
0
 private void initGraphSource(RrdGraphDef graphDef, int height, boolean maxHidden) {
   final String dataSourceName = getDataSourceName();
   final String average = "average";
   graphDef.datasource(average, rrdFileName, dataSourceName, "AVERAGE");
   graphDef.setMinValue(0);
   final String moyenneLabel = I18N.getString("Moyenne");
   graphDef.area(average, getPaint(height), moyenneLabel);
   graphDef.gprint(average, "AVERAGE", moyenneLabel + ": %9.0f %S\\r");
   // graphDef.gprint(average, "MIN", "Minimum: %9.0f %S\\r");
   if (!maxHidden) {
     final String max = "max";
     graphDef.datasource(max, rrdFileName, dataSourceName, "MAX");
     final String maximumLabel = I18N.getString("Maximum");
     graphDef.line(max, Color.BLUE, maximumLabel);
     graphDef.gprint(max, "MAX", maximumLabel + ": %9.0f %S\\r");
   }
   // graphDef.comment("JRobin :: RRDTool Choice for the Java World");
 }
  /** Sets <code>packetPerTilePart</code> */
  public void setPacketPerTilePart(int packetPerTilePart) {
    if (packetPerTilePart < 0)
      throw new IllegalArgumentException(I18N.getString("J2KImageWriteParamJava0"));

    this.packetPerTilePart = packetPerTilePart;
    if (packetPerTilePart > 0) {
      setSOP("true");
      setEPH("true");
    }
  }
Exemple #18
0
 /**
  * adds arbitrary number of data items to a log file
  *
  * @param level defines the log that will data
  * @param resourceID is used to load a string from a resource bundle
  * @param obj Array of data items to be logged
  */
 public static void add(int level, String resourceID, Object[] obj) {
   if (logLevel >= level) {
     MessageFormat mf = new MessageFormat(I18N.loadString(resourceID));
     mf.setLocale(I18N.locale);
     for (int i = 0; i < obj.length; i++) {
       obj[i] = obj[i].toString();
     }
     addInfo(mf.format(obj));
   }
 }
Exemple #19
0
 @Override
 public void layerAdded(LayerCollectionEvent e) {
   if (isOpen()) {
     for (final ILayer layer : e.getAffected()) {
       try {
         layer.open();
         layer.addLayerListenerRecursively(openerListener);
         // checking & possibly setting SRID
         // checkSRID(layer);
       } catch (LayerException ex) {
         LOGGER.error(I18N.tr("Cannot open layer : {0} ", layer.getName()), ex);
         try {
           layer.getParent().remove(layer);
         } catch (LayerException e1) {
           LOGGER.error(I18N.tr("Cannot remove the layer {0}", layer.getName()), ex);
         }
       }
     }
   }
 }
Exemple #20
0
  /**
   * Test.
   *
   * @throws IOException e
   */
  @Test
  public void testToHtmlEn() throws IOException {
    I18N.bindLocale(Locale.US);
    Locale.setDefault(Locale.US);
    try {
      assertEquals("locale en", Locale.US, I18N.getCurrentLocale());

      // counter avec 3 requêtes
      counter.addRequest("test1", 0, 0, false, 1000);
      counter.addRequest("test2", 1000, 500, false, 1000);
      counter.addRequest("test3", 10000, 5000, true, 10000);
      final HtmlReport htmlReport =
          new HtmlReport(collector, null, javaInformationsList, Period.TOUT, writer);
      htmlReport.toHtml("message", null);
      assertNotEmptyAndClear(writer);
    } finally {
      I18N.unbindLocale();
      Locale.setDefault(Locale.FRENCH);
    }
  }
Exemple #21
0
 @Override
 public void flush() throws IOException {
   super.flush();
   // Fetch lines in the byte array
   String messages = buffer.toString();
   if (!messages.isEmpty()) {
     Document doc = textComponent.getDocument();
     try {
       doc.insertString(doc.getLength(), messages, aset);
     } catch (BadLocationException ex) {
       LOGGER.error(I18N.tr("Cannot show the log message"), ex);
     }
   }
   buffer.reset();
 }
  /** Returns the data array from the <code>DataBuffer</code>. */
  private static final Object getDataBufferData(DataBuffer db) {
    Object data;

    int dType = db.getDataType();
    switch (dType) {
      case DataBuffer.TYPE_BYTE:
        data = ((DataBufferByte) db).getData();
        break;
      case DataBuffer.TYPE_USHORT:
        data = ((DataBufferUShort) db).getData();
        break;
      default:
        throw new IllegalArgumentException(I18N.getString("Generic0") + " " + dType);
    }

    return data;
  }
  public void run() {
    Logger.logInfo("[i18n] Checking for updates ...");
    File dir = new File(root);
    File tmp = new File(dir, "locale");

    if (!dir.exists() || !tmp.exists()) {
      dir.mkdirs();
      tmp.mkdirs();
    }
    cleanUpFiles();
    try {
      URLConnection connection =
          new URL(DownloadUtils.getStaticCreeperhostLink("locales")).openConnection();
      Scanner scanner = new Scanner(connection.getInputStream());
      remoteVer = scanner.nextInt();
      Logger.logInfo("[i18n] remoteVer = " + remoteVer);
      scanner.close();
    } catch (MalformedURLException e1) {
      Logger.logError(e1.getMessage(), e1);
    } catch (IOException e1) {
      Logger.logInfo("[i18n] Could not retrieve version info, skipping update.", e1);
      return;
    }
    if (local.exists()) {
      try {
        int localVer;
        Scanner scanner = new Scanner(local);
        localVer = scanner.nextInt();
        Logger.logInfo("[i18n] localVer = " + localVer);
        scanner.close();
        if (localVer < remoteVer) {
          updateFiles();
        } else {
          Logger.logInfo("[i18n] Files are up to date");
        }
      } catch (FileNotFoundException e1) {
        Logger.logInfo("[i18n] Could not read version file", e1);
      }
    } else {
      updateFiles();
    }
    I18N.addFiles();
  }
  @Override
  public TabSheet createTabs(Object itemId) throws RpcException {
    final TabSheet tabsheet = new TabSheet();
    tabsheet.addSelectedTabChangeListener(this);
    tabsheet.addTab(new GenericForm("pac", session, itemId, "name"), I18N.getText("pac"));
    final HSTab usersTab = new HSTab("user", session, "pac", itemId, "name");
    usersTab.fillTable();
    tabsheet.addTab(usersTab, I18N.getText("user"));
    final HSTab aliasTab = new HSTab("emailalias", session, "pac", itemId, "name");
    tabsheet.addTab(aliasTab, I18N.getText("emailalias"));
    final HSTab domainTab = new HSTab("domain", session, "pac", itemId, "name");
    tabsheet.addTab(domainTab, I18N.getText("domain"));

    final HSTab mysqluserTab = new HSTab("mysqluser", session, "pac", itemId, "name");
    tabsheet.addTab(mysqluserTab, I18N.getText("mysqluser"));
    final HSTab mysqldbTab = new HSTab("mysqldb", session, "pac", itemId, "name");
    tabsheet.addTab(mysqldbTab, I18N.getText("mysqldb"));
    final HSTab postgresqluserTab = new HSTab("postgresqluser", session, "pac", itemId, "name");
    tabsheet.addTab(postgresqluserTab, I18N.getText("postgresqluser"));
    final HSTab postgresqldbTab = new HSTab("postgresqldb", session, "pac", itemId, "name");
    tabsheet.addTab(postgresqldbTab, I18N.getText("postgresqldb"));
    return tabsheet;
  }
  public PasswordDialog(LaunchFrame instance, boolean modal) {
    super(instance, modal);

    setIconImage(
        Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/image/logo_ftb.png")));
    setTitle(I18N.getLocaleString("PASSWORD_TITLE"));
    setBounds(300, 300, 300, 120);
    setResizable(false);

    getRootPane().setDefaultButton(submitButton);

    panel.setBounds(0, 0, 300, 100);
    setContentPane(panel);
    panel.setLayout(null);

    passLabel.setBounds(10, 10, 80, 30);
    passLabel.setVisible(true);
    panel.add(passLabel);

    password.setBounds(100, 10, 170, 30);
    password.setVisible(true);
    panel.add(password);

    submitButton.setBounds(105, 50, 90, 25);
    submitButton.setVisible(true);
    submitButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            if (!new String(password.getPassword()).isEmpty()) {
              LaunchFrame.tempPass = new String(password.getPassword());
              setVisible(false);
            }
          }
        });
    panel.add(submitButton);
  }
 @Override
 public String toString() {
   String pattern = I18N.instance().getAnnotationDescription(description);
   FindBugsMessageFormat format = new FindBugsMessageFormat(pattern);
   return format.format(new BugAnnotation[] {this}, null);
 }
 public void actionPerformed(ActionEvent e) {
   I18N.setBundle(ResourceBundle.getBundle("resbund", new Locale(e.getActionCommand())));
   setButtonTexts();
   ((UserConsole) self.getParent().getParent().getParent()).refreshLabels();
 }
 /** Sets button label texts related to selected language */
 private void setButtonTexts() {
   okButton.setText(I18N.getText("okLabel"));
   exitButton.setText(I18N.getText("exitLabel"));
 }
 @Override
 public String getTitle() {
   return I18N.tr("Stroke and fill settings");
 }
  private Raster readSubsampledRaster(WritableRaster raster) throws IOException {
    if (raster == null)
      raster =
          Raster.createWritableRaster(
              sampleModel.createCompatibleSampleModel(
                  destinationRegion.x + destinationRegion.width,
                  destinationRegion.y + destinationRegion.height),
              new Point(destinationRegion.x, destinationRegion.y));

    int numBands = sourceBands.length;
    int dataType = sampleModel.getDataType();
    int sampleSizeBit = DataBuffer.getDataTypeSize(dataType);
    int sampleSizeByte = (sampleSizeBit + 7) / 8;

    Rectangle destRect = raster.getBounds().intersection(destinationRegion);

    int offx = destinationRegion.x;
    int offy = destinationRegion.y;

    int sourceSX = (destRect.x - offx) * scaleX + sourceOrigin.x;
    int sourceSY = (destRect.y - offy) * scaleY + sourceOrigin.y;
    int sourceEX = (destRect.width - 1) * scaleX + sourceSX;
    int sourceEY = (destRect.height - 1) * scaleY + sourceSY;
    int startXTile = sourceSX / tileWidth;
    int startYTile = sourceSY / tileHeight;
    int endXTile = sourceEX / tileWidth;
    int endYTile = sourceEY / tileHeight;

    startXTile = clip(startXTile, 0, maxXTile);
    startYTile = clip(startYTile, 0, maxYTile);
    endXTile = clip(endXTile, 0, maxXTile);
    endYTile = clip(endYTile, 0, maxYTile);

    int totalXTiles = getNumXTiles();
    int totalYTiles = getNumYTiles();
    int totalTiles = totalXTiles * totalYTiles;

    // The line buffer for the source
    byte[] pixbuf = null; // byte buffer for the decoded pixels.
    short[] spixbuf = null; // byte buffer for the decoded pixels.
    int[] ipixbuf = null; // byte buffer for the decoded pixels.
    float[] fpixbuf = null; // byte buffer for the decoded pixels.
    double[] dpixbuf = null; // byte buffer for the decoded pixels.

    // A flag to show the ComponentSampleModel has a single data bank
    boolean singleBank = true;
    int pixelStride = 0;
    int scanlineStride = 0;
    int bandStride = 0;
    int[] bandOffsets = null;
    int[] bankIndices = null;

    if (originalSampleModel instanceof ComponentSampleModel) {
      ComponentSampleModel csm = (ComponentSampleModel) originalSampleModel;
      bankIndices = csm.getBankIndices();
      int maxBank = 0;
      for (int i = 0; i < bankIndices.length; i++)
        if (maxBank > bankIndices[i]) maxBank = bankIndices[i];

      if (maxBank > 0) singleBank = false;
      pixelStride = csm.getPixelStride();

      scanlineStride = csm.getScanlineStride();
      bandOffsets = csm.getBandOffsets();
      for (int i = 0; i < bandOffsets.length; i++)
        if (bandStride < bandOffsets[i]) bandStride = bandOffsets[i];
    } else if (originalSampleModel instanceof MultiPixelPackedSampleModel) {
      scanlineStride = ((MultiPixelPackedSampleModel) originalSampleModel).getScanlineStride();
    } else if (originalSampleModel instanceof SinglePixelPackedSampleModel) {
      pixelStride = 1;
      scanlineStride = ((SinglePixelPackedSampleModel) originalSampleModel).getScanlineStride();
    }

    // The dstination buffer for the raster
    byte[] destPixbuf = null; // byte buffer for the decoded pixels.
    short[] destSPixbuf = null; // byte buffer for the decoded pixels.
    int[] destIPixbuf = null; // byte buffer for the decoded pixels.
    float[] destFPixbuf = null; // byte buffer for the decoded pixels.
    double[] destDPixbuf = null; // byte buffer for the decoded pixels.
    int[] destBandOffsets = null;
    int destPixelStride = 0;
    int destScanlineStride = 0;
    int destSX = 0; // The first pixel for the destionation

    if (raster.getSampleModel() instanceof ComponentSampleModel) {
      ComponentSampleModel csm = (ComponentSampleModel) raster.getSampleModel();
      bankIndices = csm.getBankIndices();
      destBandOffsets = csm.getBandOffsets();
      destPixelStride = csm.getPixelStride();
      destScanlineStride = csm.getScanlineStride();
      destSX =
          csm.getOffset(
                  raster.getMinX() - raster.getSampleModelTranslateX(),
                  raster.getMinY() - raster.getSampleModelTranslateY())
              - destBandOffsets[0];

      switch (dataType) {
        case DataBuffer.TYPE_BYTE:
          destPixbuf = ((DataBufferByte) raster.getDataBuffer()).getData();
          break;
        case DataBuffer.TYPE_SHORT:
          destSPixbuf = ((DataBufferShort) raster.getDataBuffer()).getData();
          break;

        case DataBuffer.TYPE_USHORT:
          destSPixbuf = ((DataBufferUShort) raster.getDataBuffer()).getData();
          break;

        case DataBuffer.TYPE_INT:
          destIPixbuf = ((DataBufferInt) raster.getDataBuffer()).getData();
          break;

        case DataBuffer.TYPE_FLOAT:
          destFPixbuf = ((DataBufferFloat) raster.getDataBuffer()).getData();
          break;

        case DataBuffer.TYPE_DOUBLE:
          destDPixbuf = ((DataBufferDouble) raster.getDataBuffer()).getData();
          break;
      }
    } else if (raster.getSampleModel() instanceof SinglePixelPackedSampleModel) {
      numBands = 1;
      bankIndices = new int[] {0};
      destBandOffsets = new int[numBands];
      for (int i = 0; i < numBands; i++) destBandOffsets[i] = 0;
      destPixelStride = 1;
      destScanlineStride =
          ((SinglePixelPackedSampleModel) raster.getSampleModel()).getScanlineStride();
    }

    // Start the data delivery to the cached consumers tile by tile
    for (int y = startYTile; y <= endYTile; y++) {
      if (reader.getAbortRequest()) break;

      // Loop on horizontal tiles
      for (int x = startXTile; x <= endXTile; x++) {
        if (reader.getAbortRequest()) break;

        long tilePosition = position + (y * originalNumXTiles + x) * tileDataSize;
        iis.seek(tilePosition);
        float percentage = (x - startXTile + y * totalXTiles) / totalXTiles;

        int startX = x * tileWidth;
        int startY = y * tileHeight;

        int cTileHeight = tileHeight;
        int cTileWidth = tileWidth;

        if (startY + cTileHeight >= originalDimension.height)
          cTileHeight = originalDimension.height - startY;

        if (startX + cTileWidth >= originalDimension.width)
          cTileWidth = originalDimension.width - startX;

        int tx = startX;
        int ty = startY;

        // If source start position calculated by taking subsampling
        // into account is after the tile's start X position, adjust
        // the start position accordingly
        if (sourceSX > startX) {
          cTileWidth += startX - sourceSX;
          tx = sourceSX;
          startX = sourceSX;
        }

        if (sourceSY > startY) {
          cTileHeight += startY - sourceSY;
          ty = sourceSY;
          startY = sourceSY;
        }

        // If source end position calculated by taking subsampling
        // into account is prior to the tile's end X position, adjust
        // the tile width to read accordingly
        if (sourceEX < startX + cTileWidth - 1) {
          cTileWidth += sourceEX - startX - cTileWidth + 1;
        }

        if (sourceEY < startY + cTileHeight - 1) {
          cTileHeight += sourceEY - startY - cTileHeight + 1;
        }

        // The start X in the destination
        int x1 = (startX + scaleX - 1 - sourceOrigin.x) / scaleX;
        int x2 = (startX + scaleX - 1 + cTileWidth - sourceOrigin.x) / scaleX;
        int lineLength = x2 - x1;
        x2 = (x2 - 1) * scaleX + sourceOrigin.x;

        int y1 = (startY + scaleY - 1 - sourceOrigin.y) / scaleY;
        startX = x1 * scaleX + sourceOrigin.x;
        startY = y1 * scaleY + sourceOrigin.y;

        // offx is destination.x
        x1 += offx;
        y1 += offy;

        tx -= x * tileWidth;
        ty -= y * tileHeight;

        if (sampleModel instanceof MultiPixelPackedSampleModel) {
          MultiPixelPackedSampleModel mppsm = (MultiPixelPackedSampleModel) originalSampleModel;

          iis.skipBytes(mppsm.getOffset(tx, ty) * sampleSizeByte);

          int readBytes =
              (mppsm.getOffset(x2, 0) - mppsm.getOffset(startX, 0) + 1) * sampleSizeByte;

          int skipLength = (scanlineStride * scaleY - readBytes) * sampleSizeByte;
          readBytes *= sampleSizeByte;

          if (pixbuf == null || pixbuf.length < readBytes) pixbuf = new byte[readBytes];

          int bitoff = mppsm.getBitOffset(tx);

          for (int l = 0, m = y1; l < cTileHeight; l += scaleY, m++) {
            if (reader.getAbortRequest()) break;
            iis.readFully(pixbuf, 0, readBytes);
            if (scaleX == 1) {

              if (bitoff != 0) {
                int mask1 = (255 << bitoff) & 255;
                int mask2 = ~mask1 & 255;
                int shift = 8 - bitoff;

                int n = 0;
                for (; n < readBytes - 1; n++)
                  pixbuf[n] =
                      (byte) (((pixbuf[n] & mask2) << shift) | (pixbuf[n + 1] & mask1) >> bitoff);
                pixbuf[n] = (byte) ((pixbuf[n] & mask2) << shift);
              }
            } else {

              int bit = 7;
              int pos = 0;
              int mask = 128;

              for (int n = 0, n1 = startX & 7; n < lineLength; n++, n1 += scaleX) {
                pixbuf[pos] =
                    (byte)
                        ((pixbuf[pos] & ~(1 << bit))
                            | (((pixbuf[n1 >> 3] >> (7 - (n1 & 7))) & 1) << bit));
                bit--;
                if (bit == -1) {
                  bit = 7;
                  pos++;
                }
              }
            }

            ImageUtil.setPackedBinaryData(pixbuf, raster, new Rectangle(x1, m, lineLength, 1));
            iis.skipBytes(skipLength);
            if (destImage != null)
              reader.processImageUpdateWrapper(
                  destImage, x1, m, cTileWidth, 1, 1, 1, destinationBands);

            reader.processImageProgressWrapper(
                percentage + (l - startY + 1.0F) / cTileHeight / totalTiles);
          }
        } else {

          int readLength, skipLength;
          if (pixelStride < scanlineStride) {
            readLength = cTileWidth * pixelStride;
            skipLength = (scanlineStride * scaleY - readLength) * sampleSizeByte;
          } else {
            readLength = cTileHeight * scanlineStride;
            skipLength = (pixelStride * scaleX - readLength) * sampleSizeByte;
          }

          // Allocate buffer for all the types
          switch (sampleModel.getDataType()) {
            case DataBuffer.TYPE_BYTE:
              if (pixbuf == null || pixbuf.length < readLength) pixbuf = new byte[readLength];
              break;

            case DataBuffer.TYPE_SHORT:
            case DataBuffer.TYPE_USHORT:
              if (spixbuf == null || spixbuf.length < readLength) spixbuf = new short[readLength];
              break;

            case DataBuffer.TYPE_INT:
              if (ipixbuf == null || ipixbuf.length < readLength) ipixbuf = new int[readLength];
              break;

            case DataBuffer.TYPE_FLOAT:
              if (fpixbuf == null || fpixbuf.length < readLength) fpixbuf = new float[readLength];
              break;

            case DataBuffer.TYPE_DOUBLE:
              if (dpixbuf == null || dpixbuf.length < readLength) dpixbuf = new double[readLength];
              break;
          }

          if (sampleModel instanceof PixelInterleavedSampleModel) {
            iis.skipBytes((tx * pixelStride + ty * scanlineStride) * sampleSizeByte);

            // variables for ther loop
            int outerFirst, outerSecond, outerStep, outerBound;
            int innerStep, innerStep1, outerStep1;
            if (pixelStride < scanlineStride) {
              outerFirst = 0;
              outerSecond = y1;
              outerStep = scaleY;
              outerBound = cTileHeight;
              innerStep = scaleX * pixelStride;
              innerStep1 = destPixelStride;
              outerStep1 = destScanlineStride;
            } else {
              outerFirst = 0;
              outerSecond = x1;
              outerStep = scaleX;
              outerBound = cTileWidth;
              innerStep = scaleY * scanlineStride;
              innerStep1 = destScanlineStride;
              outerStep1 = destPixelStride;
            }

            int destPos =
                destSX
                    + (y1 - raster.getSampleModelTranslateY()) * destScanlineStride
                    + (x1 - raster.getSampleModelTranslateX()) * destPixelStride;

            for (int l = outerFirst, m = outerSecond; l < outerBound; l += outerStep, m++) {
              if (reader.getAbortRequest()) break;

              switch (dataType) {
                case DataBuffer.TYPE_BYTE:
                  if (innerStep == numBands && innerStep1 == numBands)
                    iis.readFully(destPixbuf, destPos, readLength);
                  else iis.readFully(pixbuf, 0, readLength);
                  break;
                case DataBuffer.TYPE_SHORT:
                case DataBuffer.TYPE_USHORT:
                  if (innerStep == numBands && innerStep1 == numBands) {
                    iis.readFully(destSPixbuf, destPos, readLength);
                  } else iis.readFully(spixbuf, 0, readLength);
                  break;
                case DataBuffer.TYPE_INT:
                  if (innerStep == numBands && innerStep1 == numBands)
                    iis.readFully(destIPixbuf, destPos, readLength);
                  else iis.readFully(ipixbuf, 0, readLength);
                  break;
                case DataBuffer.TYPE_FLOAT:
                  if (innerStep == numBands && innerStep1 == numBands)
                    iis.readFully(destFPixbuf, destPos, readLength);
                  else iis.readFully(fpixbuf, 0, readLength);
                  break;
                case DataBuffer.TYPE_DOUBLE:
                  if (innerStep == numBands && innerStep1 == numBands)
                    iis.readFully(destDPixbuf, destPos, readLength);
                  else iis.readFully(dpixbuf, 0, readLength);
                  break;
              }

              if (innerStep != numBands || innerStep1 != numBands)
                for (int b = 0; b < numBands; b++) {
                  int destBandOffset = destBandOffsets[destinationBands[b]];
                  destPos += destBandOffset;

                  int sourceBandOffset = bandOffsets[sourceBands[b]];

                  switch (dataType) {
                    case DataBuffer.TYPE_BYTE:
                      for (int m1 = 0, n = destPos;
                          m1 < readLength;
                          m1 += innerStep, n += innerStep1) {
                        destPixbuf[n] = pixbuf[m1 + sourceBandOffset];
                      }
                      break;
                    case DataBuffer.TYPE_SHORT:
                    case DataBuffer.TYPE_USHORT:
                      for (int m1 = 0, n = destPos;
                          m1 < readLength;
                          m1 += innerStep, n += innerStep1) {
                        destSPixbuf[n] = spixbuf[m1 + sourceBandOffset];
                      }
                      break;
                    case DataBuffer.TYPE_INT:
                      for (int m1 = 0, n = destPos;
                          m1 < readLength;
                          m1 += innerStep, n += innerStep1) {
                        destIPixbuf[n] = ipixbuf[m1 + sourceBandOffset];
                      }
                      break;
                    case DataBuffer.TYPE_FLOAT:
                      for (int m1 = 0, n = destPos;
                          m1 < readLength;
                          m1 += innerStep, n += innerStep1) {
                        destFPixbuf[n] = fpixbuf[m1 + sourceBandOffset];
                      }
                      break;
                    case DataBuffer.TYPE_DOUBLE:
                      for (int m1 = 0, n = destPos;
                          m1 < readLength;
                          m1 += innerStep, n += innerStep1) {
                        destDPixbuf[n] = dpixbuf[m1 + sourceBandOffset];
                      }
                      break;
                  }
                  destPos -= destBandOffset;
                }

              iis.skipBytes(skipLength);
              destPos += outerStep1;

              if (destImage != null)
                if (pixelStride < scanlineStride)
                  reader.processImageUpdateWrapper(
                      destImage, x1, m, outerBound, 1, 1, 1, destinationBands);
                else
                  reader.processImageUpdateWrapper(
                      destImage, m, y1, 1, outerBound, 1, 1, destinationBands);

              reader.processImageProgressWrapper(percentage + (l + 1.0F) / outerBound / totalTiles);
            }
          } else if (sampleModel instanceof BandedSampleModel
              || sampleModel instanceof SinglePixelPackedSampleModel
              || bandStride == 0) {
            boolean isBanded = sampleModel instanceof BandedSampleModel;

            int bandSize = (int) ImageUtil.getBandSize(originalSampleModel);

            for (int b = 0; b < numBands; b++) {
              iis.seek(tilePosition + bandSize * sourceBands[b] * sampleSizeByte);
              int destBandOffset = destBandOffsets[destinationBands[b]];

              iis.skipBytes((ty * scanlineStride + tx * pixelStride) * sampleSizeByte);

              // variables for ther loop
              int outerFirst, outerSecond, outerStep, outerBound;
              int innerStep, innerStep1, outerStep1;
              if (pixelStride < scanlineStride) {
                outerFirst = 0;
                outerSecond = y1;
                outerStep = scaleY;
                outerBound = cTileHeight;
                innerStep = scaleX * pixelStride;
                innerStep1 = destPixelStride;
                outerStep1 = destScanlineStride;
              } else {
                outerFirst = 0;
                outerSecond = x1;
                outerStep = scaleX;
                outerBound = cTileWidth;
                innerStep = scaleY * scanlineStride;
                innerStep1 = destScanlineStride;
                outerStep1 = destPixelStride;
              }

              int destPos =
                  destSX
                      + (y1 - raster.getSampleModelTranslateY()) * destScanlineStride
                      + (x1 - raster.getSampleModelTranslateX()) * destPixelStride
                      + destBandOffset;

              int bank = bankIndices[destinationBands[b]];

              switch (dataType) {
                case DataBuffer.TYPE_BYTE:
                  destPixbuf = ((DataBufferByte) raster.getDataBuffer()).getData(bank);
                  break;
                case DataBuffer.TYPE_SHORT:
                  destSPixbuf = ((DataBufferShort) raster.getDataBuffer()).getData(bank);
                  break;

                case DataBuffer.TYPE_USHORT:
                  destSPixbuf = ((DataBufferUShort) raster.getDataBuffer()).getData(bank);
                  break;

                case DataBuffer.TYPE_INT:
                  destIPixbuf = ((DataBufferInt) raster.getDataBuffer()).getData(bank);
                  break;

                case DataBuffer.TYPE_FLOAT:
                  destFPixbuf = ((DataBufferFloat) raster.getDataBuffer()).getData(bank);
                  break;

                case DataBuffer.TYPE_DOUBLE:
                  destDPixbuf = ((DataBufferDouble) raster.getDataBuffer()).getData(bank);
                  break;
              }

              for (int l = outerFirst, m = outerSecond; l < outerBound; l += outerStep, m++) {
                if (reader.getAbortRequest()) break;

                switch (dataType) {
                  case DataBuffer.TYPE_BYTE:
                    if (innerStep == 1 && innerStep1 == 1) {
                      iis.readFully(destPixbuf, destPos, readLength);
                    } else {
                      iis.readFully(pixbuf, 0, readLength);
                      for (int m1 = 0, n = destPos;
                          m1 < readLength;
                          m1 += innerStep, n += innerStep1) {
                        destPixbuf[n] = pixbuf[m1];
                      }
                    }
                    break;
                  case DataBuffer.TYPE_SHORT:
                  case DataBuffer.TYPE_USHORT:
                    if (innerStep == 1 && innerStep1 == 1) {
                      iis.readFully(destSPixbuf, destPos, readLength);
                    } else {
                      iis.readFully(spixbuf, 0, readLength);
                      for (int m1 = 0, n = destPos;
                          m1 < readLength;
                          m1 += innerStep, n += innerStep1) {
                        destSPixbuf[n] = spixbuf[m1];
                      }
                    }
                    break;
                  case DataBuffer.TYPE_INT:
                    if (innerStep == 1 && innerStep1 == 1) {
                      iis.readFully(destIPixbuf, destPos, readLength);
                    } else {
                      iis.readFully(ipixbuf, 0, readLength);
                      for (int m1 = 0, n = destPos;
                          m1 < readLength;
                          m1 += innerStep, n += innerStep1) {
                        destIPixbuf[n] = ipixbuf[m1];
                      }
                    }
                    break;
                  case DataBuffer.TYPE_FLOAT:
                    if (innerStep == 1 && innerStep1 == 1) {
                      iis.readFully(destFPixbuf, destPos, readLength);
                    } else {
                      iis.readFully(fpixbuf, 0, readLength);
                      for (int m1 = 0, n = destPos;
                          m1 < readLength;
                          m1 += innerStep, n += innerStep1) {
                        destFPixbuf[n] = fpixbuf[m1];
                      }
                    }
                    break;
                  case DataBuffer.TYPE_DOUBLE:
                    if (innerStep == 1 && innerStep1 == 1) {
                      iis.readFully(destDPixbuf, destPos, readLength);
                    } else {
                      iis.readFully(dpixbuf, 0, readLength);
                      for (int m1 = 0, n = destPos;
                          m1 < readLength;
                          m1 += innerStep, n += innerStep1) {
                        destDPixbuf[n] = dpixbuf[m1];
                      }
                    }
                    break;
                }

                iis.skipBytes(skipLength);
                destPos += outerStep1;

                if (destImage != null) {
                  int[] destBands = new int[] {destinationBands[b]};
                  if (pixelStride < scanlineStride)
                    reader.processImageUpdateWrapper(
                        destImage, x1, m, outerBound, 1, 1, 1, destBands);
                  else
                    reader.processImageUpdateWrapper(
                        destImage, m, y1, 1, outerBound, 1, 1, destBands);
                }

                reader.processImageProgressWrapper(
                    (percentage + (l + 1.0F) / outerBound / numBands / totalTiles) * 100.0F);
              }
            }
          } else if (sampleModel instanceof ComponentSampleModel) {
            // for the other case, may slow
            // Allocate buffer for all the types
            int bufferSize = (int) tileDataSize;

            switch (sampleModel.getDataType()) {
              case DataBuffer.TYPE_BYTE:
                if (pixbuf == null || pixbuf.length < tileDataSize)
                  pixbuf = new byte[(int) tileDataSize];
                iis.readFully(pixbuf, 0, (int) tileDataSize);
                break;

              case DataBuffer.TYPE_SHORT:
              case DataBuffer.TYPE_USHORT:
                bufferSize /= 2;
                if (spixbuf == null || spixbuf.length < bufferSize)
                  spixbuf = new short[(int) bufferSize];
                iis.readFully(spixbuf, 0, (int) bufferSize);
                break;

              case DataBuffer.TYPE_INT:
                bufferSize /= 4;
                if (ipixbuf == null || ipixbuf.length < bufferSize)
                  ipixbuf = new int[(int) bufferSize];
                iis.readFully(ipixbuf, 0, (int) bufferSize);
                break;

              case DataBuffer.TYPE_FLOAT:
                bufferSize /= 4;
                if (fpixbuf == null || fpixbuf.length < bufferSize)
                  fpixbuf = new float[(int) bufferSize];
                iis.readFully(fpixbuf, 0, (int) bufferSize);
                break;

              case DataBuffer.TYPE_DOUBLE:
                bufferSize /= 8;
                if (dpixbuf == null || dpixbuf.length < bufferSize)
                  dpixbuf = new double[(int) bufferSize];
                iis.readFully(dpixbuf, 0, (int) bufferSize);
                break;
            }

            for (int b = 0; b < numBands; b++) {
              int destBandOffset = destBandOffsets[destinationBands[b]];

              int destPos =
                  ((ComponentSampleModel) raster.getSampleModel())
                      .getOffset(
                          x1 - raster.getSampleModelTranslateX(),
                          y1 - raster.getSampleModelTranslateY(),
                          destinationBands[b]);

              int bank = bankIndices[destinationBands[b]];

              switch (dataType) {
                case DataBuffer.TYPE_BYTE:
                  destPixbuf = ((DataBufferByte) raster.getDataBuffer()).getData(bank);
                  break;
                case DataBuffer.TYPE_SHORT:
                  destSPixbuf = ((DataBufferShort) raster.getDataBuffer()).getData(bank);
                  break;

                case DataBuffer.TYPE_USHORT:
                  destSPixbuf = ((DataBufferUShort) raster.getDataBuffer()).getData(bank);
                  break;

                case DataBuffer.TYPE_INT:
                  destIPixbuf = ((DataBufferInt) raster.getDataBuffer()).getData(bank);
                  break;

                case DataBuffer.TYPE_FLOAT:
                  destFPixbuf = ((DataBufferFloat) raster.getDataBuffer()).getData(bank);
                  break;

                case DataBuffer.TYPE_DOUBLE:
                  destDPixbuf = ((DataBufferDouble) raster.getDataBuffer()).getData(bank);
                  break;
              }

              int srcPos =
                  ((ComponentSampleModel) originalSampleModel).getOffset(tx, ty, sourceBands[b]);
              int skipX = scaleX * pixelStride;
              ;
              for (int l = 0, m = y1; l < cTileHeight; l += scaleY, m++) {
                if (reader.getAbortRequest()) break;

                switch (dataType) {
                  case DataBuffer.TYPE_BYTE:
                    for (int n = 0, m1 = srcPos, m2 = destPos;
                        n < lineLength;
                        n++, m1 += skipX, m2 += destPixelStride) destPixbuf[m2] = pixbuf[m1];
                    break;
                  case DataBuffer.TYPE_SHORT:
                  case DataBuffer.TYPE_USHORT:
                    for (int n = 0, m1 = srcPos, m2 = destPos;
                        n < lineLength;
                        n++, m1 += skipX, m2 += destPixelStride) destSPixbuf[m2] = spixbuf[m1];
                    break;
                  case DataBuffer.TYPE_INT:
                    for (int n = 0, m1 = srcPos, m2 = destPos;
                        n < lineLength;
                        n++, m1 += skipX, m2 += destPixelStride) destIPixbuf[m2] = ipixbuf[m1];
                    break;
                  case DataBuffer.TYPE_FLOAT:
                    for (int n = 0, m1 = srcPos, m2 = destPos;
                        n < lineLength;
                        n++, m1 += skipX, m2 += destPixelStride) destFPixbuf[m2] = fpixbuf[m1];
                    break;
                  case DataBuffer.TYPE_DOUBLE:
                    for (int n = 0, m1 = srcPos, m2 = destPos;
                        n < lineLength;
                        n++, m1 += skipX, m2 += destPixelStride) destDPixbuf[m2] = dpixbuf[m1];
                    break;
                }

                destPos += destScanlineStride;
                srcPos += scanlineStride * scaleY;

                if (destImage != null) {
                  int[] destBands = new int[] {destinationBands[b]};
                  reader.processImageUpdateWrapper(
                      destImage, x1, m, cTileHeight, 1, 1, 1, destBands);
                }

                reader.processImageProgressWrapper(
                    percentage + (l + 1.0F) / cTileHeight / numBands / totalTiles);
              }
            }
          } else {
            throw new IllegalArgumentException(I18N.getString("RawRenderedImage1"));
          }
        }
      } // End loop on horizontal tiles
    } // End loop on vertical tiles

    return raster;
  }