text:
package jwave.transforms;

import jwave.datatypes.natives.Complex;
import jwave.exceptions.JWaveError;
import jwave.exceptions.JWaveException;
import jwave.exceptions.JWaveFailure;
import jwave.tools.MathToolKit;
import jwave.transforms.wavelets.Wavelet;

/**
 * Basic Wave for transformations like Fast Fourier Transform (FFT), Fast
 * Wavelet Transform (FWT), Fast Wavelet Packet Transform (WPT), or Discrete
 * Wavelet Transform (DWT). Naming of this class due to en.wikipedia.org; to
 * write Fourier series in terms of the 'basic waves' of function: e^(2*pi*i*w).
 *
 * @date 08.02.2010 11:11:59
 * @author Christian Scheiblich (cscheiblich@gmail.com)
 */
public abstract class BasicTransform {

  /**
   * String identifier of the current Transform object.
   *
   * @author Christian Scheiblich (cscheiblich@gmail.com)
   * @date 14.03.2015 14:25:56
   */
  protected String _name;

  /**
   * @author Christian Scheiblich (cscheiblich@gmail.com)
   * @date 19.02.2014 18:38:21
   */
  public BasicTransform( ) {

    _name = null;

  } // BasicTransform

  /**
   * Returns String identifier of current type of BasicTransform Object.
   *
   * @author Christian Scheiblich (cscheiblich@gmail.com)
   * @date 14.03.2015 18:13:34
   * @return identifier as String
   */
  public String getName( ) {
    return _name;
  } // getName

  /**
   * Returns the stored Wavelet object or null pointer.
   *
   * @author Christian Scheiblich (cscheiblich@gmail.com)
   * @date 14.03.2015 18:26:44
   * @return object of type Wavelet of null pointer
   * @throws JWaveFailure
   *           if Wavelet object is not available
   */
  public Wavelet getWavelet( ) throws JWaveFailure {
    throw new JWaveFailure(
        "BasicTransform#getWavelet - not available" );
  } // getWavelet

  /**
   * Performs the forward transform from time domain to frequency or Hilbert
   * domain for a given array depending on the used transform algorithm by
   * inheritance.
   *
   * @date 10.02.2010 08:23:24
   * @author Christian Scheiblich (cscheiblich@gmail.com)
   * @param arrTime
   *          coefficients of 1-D time domain
   * @return coefficients of 1-D frequency or Hilbert space
   * @throws JWaveException
   */
  public abstract double[ ] forward( double[ ] arrTime ) throws JWaveException;

  /**
   * Performs the reverse transform from frequency or Hilbert domain to time
   * domain for a given array depending on the used transform algorithm by
   * inheritance.
   *
   * @date 10.02.2010 08:23:24
   * @author Christian Scheiblich (cscheiblich@gmail.com)
   * @param arrFreq
   *          coefficients of 1-D frequency or Hilbert domain
   * @return coefficients of time series of 1-D frequency or Hilbert space
   * @throws JWaveException
   */
  public abstract double[ ] reverse( double[ ] arrFreq ) throws JWaveException;

  /**
   * Performs the forward transform from time domain to Hilbert domain of a
   * given level depending on the used transform algorithm by inheritance.
   *
   * @author Christian Scheiblich (cscheiblich@gmail.com)
   * @date 22.03.2015 11:33:11
   * @param arrTime
   * @param level
   *          the level of Hilbert space; energy & detail coefficients
   * @return array keeping Hilbert space of requested level
   * @throws JWaveException
   *           if given array is not of type 2^p | p € N or given level does not
   *           match the possibilities of given array.
   */
  public double[ ] forward( double[ ] arrTime, int level )
      throws JWaveException {

    throw new JWaveError( "BasicTransform#forward - "
        + "method is not implemented for this transform type!" );

  } // forward

  /**
   * Performs the reverse transform from Hilbert domain of a given level to time
   * domain depending on the used transform algorithm by inheritance.
   *
   * @author Christian Scheiblich (cscheiblich@gmail.com)
   * @date 22.03.2015 11:34:27
   * @param arrFreq
   * @param level
   *          the level of Hilbert space; energy & detail coefficients
   * @return array keeping Hilbert space of requested level
   * @throws JWaveException
   *           if given array is not of type 2^p | p € N or given level does not
   *           match the possibilities of given array.
   */
  public double[ ] reverse( double[ ] arrFreq, int level )
      throws JWaveException {

    throw new JWaveError( "BasicTransform#reverse - "
        + "method is not implemented for this transform type!" );

  } // reverse

  /**
   * Generates from a 2-D decomposition a 1-D time series.
   *
   * @author Christian Scheiblich (cscheiblich@gmail.com)
   * @date 17.08.2014 10:07:19
   * @param matDeComp
   *          2-D Hilbert spaces: [ 0 .. p ][ 0 .. N ] where p is the exponent
   *          of N=2^p
   * @return a 1-D time domain signal
   * @throws JWaveException
   */
  public double[ ][ ] decompose( double[ ] arrTime ) throws JWaveException {

    throw new JWaveError( "BasicTransform#decompose - "
        + "method is not implemented for this transform type!" );

  } // decompose

  /**
   * Generates from a 1-D signal a 2-D output, where the second dimension are
   * the levels of the wavelet transform. The first level should keep the
   * original coefficients. All following levels should keep each step of the
   * decomposition of the Fast Wavelet Transform. However, each level of the
   * this decomposition matrix is having the full set, full energy and full
   * details, that are needed to do a full reconstruction. So one can select a
   * level filter it and then do reconstruction only from this single line! BY
   * THIS METHOD, THE _HIGHEST_ LEVEL IS _ALWAYS_ TAKEN FOR RECONSTRUCTION!
   *
   * @author Christian Scheiblich (cscheiblich@gmail.com)
   * @date 17.08.2014 10:07:19
   * @param matDeComp
   *          2-D Hilbert spaces: [ 0 .. p ][ 0 .. M ] where p is the exponent
   *          of M=2^p | p€N
   * @return a 1-D time domain signal
   */
  public double[ ] recompose( double[ ][ ] matDeComp ) throws JWaveException {

    // Each level of the matrix is having the full set (full energy + details)
    // of decomposition. Therefore, each level can be used to do a full reconstruction,
    int level = matDeComp.length - 1; // selected highest level in general.
    double[ ] arrTime = null;
    try {
      arrTime = recompose( matDeComp, level );
    } catch( JWaveFailure e ) {
      e.showMessage( );
      e.printStackTrace( );
    } // try

    return arrTime;

  } // recompose

  /**
   * Generates from a 1-D signal a 2-D output, where the second dimension are
   * the levels of the wavelet transform. The first level should keep the
   * original coefficients. All following levels should keep each step of the
   * decomposition of the Fast Wavelet Transform. However, each level of the
   * this decomposition matrix is having the full set, full energy and full
   * details, that are needed to do a full reconstruction. So one can select a
   * level filter it and then do reconstruction only from this single line!
   *
   * @author Christian Scheiblich (cscheiblich@gmail.com)
   * @date 22.03.2015 15:12:19
   * @param matDeComp
   *          2-D Hilbert spaces: [ 0 .. p ][ 0 .. M ] where p is the exponent
   *          of M=2^p | p€N
   * @param level
   *          the level that should be used for reconstruction
   * @return the reconstructed time series of a selected level
   * @throws JWaveException
   */
  public double[ ] recompose( double[ ][ ] matDeComp, int level )
      throws JWaveException {

    double[ ] arrTime = null;
    try {
      arrTime = recompose( matDeComp, level );
    } catch( JWaveFailure e ) {
      e.showMessage( );
      e.printStackTrace( );
    } // try

    return arrTime;

  } // recompose

  /**
   * Performs the forward transform from time domain to frequency or Hilbert
   * domain for a given array depending on the used transform algorithm by
   * inheritance.
   *
   * @date 16.02.2014 14:42:57
   * @author Christian Scheiblich (cscheiblich@gmail.com)
   *         (cscheiblich@gmail.com)
   * @param arrTime
   *          coefficients of 1-D time domain
   * @return coefficients of 1-D frequency or Hilbert domain
   * @throws JWaveException
   */
  public Complex[ ] forward( Complex[ ] arrTime ) throws JWaveException {

    double[ ] arrTimeBulk = new double[ 2 * arrTime.length ];

    for( int i = 0; i < arrTime.length; i++ ) {

      // TODO rehack complex number splitting this to: { r1, r2, r3, .., c1, c2, c3, .. }
      int k = i * 2;
      arrTimeBulk[ k ] = arrTime[ i ].getReal( );
      arrTimeBulk[ k + 1 ] = arrTime[ i ].getImag( );

    } // i blown to k = 2 * i

    double[ ] arrHilbBulk = forward( arrTimeBulk );

    Complex[ ] arrHilb = new Complex[ arrTime.length ];

    for( int i = 0; i < arrTime.length; i++ ) {

      int k = i * 2;
      arrHilb[ i ] = new Complex( arrHilbBulk[ k ], arrHilbBulk[ k + 1 ] );

    } // k = 2 * i shrink to i

    return arrHilb;

  } // forward

  /**
   * Performs the reverse transform from frequency or Hilbert domain to time
   * domain for a given array depending on the used transform algorithm by
   * inheritance.
   *
   * @date 16.02.2014 14:42:57
   * @author Christian Scheiblich (cscheiblich@gmail.com)
   *         (cscheiblich@gmail.com)
   * @param arrFreq
   *          coefficients of 1-D frequency or Hilbert domain
   * @return coefficients of 1-D time domain
   * @throws JWaveException
   */
  public Complex[ ] reverse( Complex[ ] arrHilb ) throws JWaveException {

    double[ ] arrHilbBulk = new double[ 2 * arrHilb.length ];

    for( int i = 0; i < arrHilb.length; i++ ) {

      int k = i * 2;
      arrHilbBulk[ k ] = arrHilb[ i ].getReal( );
      arrHilbBulk[ k + 1 ] = arrHilb[ i ].getImag( );

    } // i blown to k = 2 * i

    double[ ] arrTimeBulk = reverse( arrHilbBulk );

    Complex[ ] arrTime = new Complex[ arrHilb.length ];

    for( int i = 0; i < arrTime.length; i++ ) {

      int k = i * 2;
      arrTime[ i ] = new Complex( arrTimeBulk[ k ], arrTimeBulk[ k + 1 ] );

    } // k = 2 * i shrink to i

    return arrTime;

  } // reverse

  /**
   * Performs the 2-D forward transform from time domain to frequency or Hilbert
   * domain for a given matrix depending on the used transform algorithm by
   * inheritance.
   *
   * @author Christian Scheiblich (cscheiblich@gmail.com)
   * @date 22.03.2015 12:47:01
   * @param matTime
   * @return
   * @throws JWaveException
   *           if matrix id not of matching dimension like 2^p | p€N
   */
  public double[ ][ ] forward( double[ ][ ] matTime ) throws JWaveException {

    int maxM = MathToolKit.getExponent( matTime.length );
    int maxN = MathToolKit.getExponent( matTime[ 0 ].length );
    return forward( matTime, maxM, maxN );

  } // forward

  /**
   * Performs the 2-D forward transform from time domain to frequency or Hilbert
   * domain of a certain level for a given matrix depending on the used
   * transform algorithm by inheritance. The supported level has to match the
   * possible dimensions of the given matrix.
   *
   * @date 10.02.2010 11:00:29
   * @author Christian Scheiblich (cscheiblich@gmail.com)
   * @param matTime
   *          coefficients of 2-D time domain
   * @param lvlM
   *          level to stop in dimension M of the matrix
   * @param lvlN
   *          level to stop in dimension N of the matrix
   * @return coefficients of 2-D frequency or Hilbert domain
   * @throws JWaveException
   */
  public double[ ][ ] forward( double[ ][ ] matTime, int lvlM, int lvlN )
      throws JWaveException {

    int noOfRows = matTime.length;
    int noOfCols = matTime[ 0 ].length;

    double[ ][ ] matHilb = new double[ noOfRows ][ noOfCols ];

    for( int i = 0; i < noOfRows; i++ ) {

      double[ ] arrTime = new double[ noOfCols ];

      for( int j = 0; j < noOfCols; j++ )
        arrTime[ j ] = matTime[ i ][ j ];

      double[ ] arrHilb = forward( arrTime, lvlN );

      for( int j = 0; j < noOfCols; j++ )
        matHilb[ i ][ j ] = arrHilb[ j ];

    } // rows

    for( int j = 0; j < noOfCols; j++ ) {

      double[ ] arrTime = new double[ noOfRows ];

      for( int i = 0; i < noOfRows; i++ )
        arrTime[ i ] = matHilb[ i ][ j ];

      double[ ] arrHilb = forward( arrTime, lvlM );

      for( int i = 0; i < noOfRows; i++ )
        matHilb[ i ][ j ] = arrHilb[ i ];

    } // cols

    return matHilb;

  } // forward

  /**
   * Performs the 2-D reverse transform from frequency or Hilbert or time domain
   * to time domain for a given matrix depending on the used transform algorithm
   * by inheritance.
   *
   * @author Christian Scheiblich (cscheiblich@gmail.com)
   * @date 10.02.2010 11:01:38
   * @param matFreq
   * @return
   * @throws JWaveException
   */
  public double[ ][ ] reverse( double[ ][ ] matFreq ) throws JWaveException {

    int maxM = MathToolKit.getExponent( matFreq.length );
    int maxN = MathToolKit.getExponent( matFreq[ 0 ].length );
    return reverse( matFreq, maxM, maxN );

  } // reverse

  /**
   * Performs the 2-D reverse transform from frequency or Hilbert or time domain
   * to time domain of a certain level for a given matrix depending on the used
   * transform algorithm by inheritance.
   *
   * @date 22.03.2015 12:49:16
   * @author Christian Scheiblich (cscheiblich@gmail.com)
   * @param matFreq
   *          coefficients of 2-D frequency or Hilbert domain
   * @param lvlM
   *          level to start reconstruction for dimension M of the matrix
   * @param lvlN
   *          level to start reconstruction for dimension N of the matrix
   * @return coefficients of 2-D time domain
   * @throws JWaveException
   */
  public double[ ][ ] reverse( double[ ][ ] matFreq, int lvlM, int lvlN )
      throws JWaveException {

    int noOfRows = matFreq.length;
    int noOfCols = matFreq[ 0 ].length;

    double[ ][ ] matTime = new double[ noOfRows ][ noOfCols ];

    for( int j = 0; j < noOfCols; j++ ) {

      double[ ] arrFreq = new double[ noOfRows ];

      for( int i = 0; i < noOfRows; i++ )
        arrFreq[ i ] = matFreq[ i ][ j ];

      double[ ] arrTime = reverse( arrFreq, lvlM ); // AED

      for( int i = 0; i < noOfRows; i++ )
        matTime[ i ][ j ] = arrTime[ i ];

    } // cols

    for( int i = 0; i < noOfRows; i++ ) {

      double[ ] arrFreq = new double[ noOfCols ];

      for( int j = 0; j < noOfCols; j++ )
        arrFreq[ j ] = matTime[ i ][ j ];

      double[ ] arrTime = reverse( arrFreq, lvlN ); // AED

      for( int j = 0; j < noOfCols; j++ )
        matTime[ i ][ j ] = arrTime[ j ];

    } // rows

    return matTime;

  } // reverse

  /**
   * Performs the 3-D forward transform from time domain to frequency or Hilbert
   * domain for a given space (3-D) depending on the used transform algorithm by
   * inheritance.
   *
   * @author Christian Scheiblich (cscheiblich@gmail.com)
   * @date 10.07.2010 18:08:17
   * @param spcTime
   * @return
   * @throws JWaveException
   */
  public double[ ][ ][ ] forward( double[ ][ ][ ] spcTime )
      throws JWaveException {

    int maxP = MathToolKit.getExponent( spcTime.length );
    int maxQ = MathToolKit.getExponent( spcTime[ 0 ].length );
    int maxR = MathToolKit.getExponent( spcTime[ 0 ][ 0 ].length );
    return forward( spcTime, maxP, maxQ, maxR );

  } // forward

  /**
   * Performs the 3-D forward transform from time domain to frequency or Hilbert
   * domain of a certain level for a given space (3-D) depending on the used
   * transform algorithm by inheritance.
   *
   * @author Christian Scheiblich (cscheiblich@gmail.com)
   * @date 22.03.2015 12:58:34
   * @param spcTime
   *          coefficients of 3-D time domain domain
   * @return coefficients of 3-D frequency or Hilbert domain
   * @throws JWaveException
   */
  public double[ ][ ][ ] forward( double[ ][ ][ ] spcTime, int lvlP, int lvlQ,
      int lvlR ) throws JWaveException {

    int noOfRows = spcTime.length; // first dimension
    int noOfCols = spcTime[ 0 ].length; // second dimension
    int noOfHigh = spcTime[ 0 ][ 0 ].length; // third dimension

    double[ ][ ][ ] spcHilb = new double[ noOfRows ][ noOfCols ][ noOfHigh ];

    for( int i = 0; i < noOfRows; i++ ) {

      double[ ][ ] matTime = new double[ noOfCols ][ noOfHigh ];

      for( int j = 0; j < noOfCols; j++ ) {

        for( int k = 0; k < noOfHigh; k++ ) {

          matTime[ j ][ k ] = spcTime[ i ][ j ][ k ];

        } // high

      } // cols

      double[ ][ ] matHilb = forward( matTime, lvlP, lvlQ ); // 2-D forward

      for( int j = 0; j < noOfCols; j++ ) {

        for( int k = 0; k < noOfHigh; k++ ) {

          spcHilb[ i ][ j ][ k ] = matHilb[ j ][ k ];

        } // high

      } // cols

    } // rows

    for( int j = 0; j < noOfCols; j++ ) {

      for( int k = 0; k < noOfHigh; k++ ) {

        double[ ] arrTime = new double[ noOfRows ];

        for( int i = 0; i < noOfRows; i++ )
          arrTime[ i ] = spcHilb[ i ][ j ][ k ];

        double[ ] arrHilb = forward( arrTime, lvlR ); // 1-D forward

        for( int i = 0; i < noOfRows; i++ )
          spcHilb[ i ][ j ][ k ] = arrHilb[ i ];

      } // high

    } // cols

    return spcHilb;

  } // forward

  /**
   * Performs the 3-D reverse transform from frequency or Hilbert domain to time
   * domain for a given space (3-D) depending on the used transform algorithm by
   * inheritance.
   *
   * @author Christian Scheiblich (cscheiblich@gmail.com)
   * @date 10.07.2010 18:09:54
   * @param spcHilb
   * @return
   * @throws JWaveException
   */
  public double[ ][ ][ ] reverse( double[ ][ ][ ] spcHilb )
      throws JWaveException {

    int maxP = MathToolKit.getExponent( spcHilb.length );
    int maxQ = MathToolKit.getExponent( spcHilb[ 0 ].length );
    int maxR = MathToolKit.getExponent( spcHilb[ 0 ][ 0 ].length );
    return reverse( spcHilb, maxP, maxQ, maxR );

  } // reverse

  /**
   * Performs the 3-D reverse transform from frequency or Hilbert domain of a
   * certain level to time domain for a given space (3-D) depending on the used
   * transform algorithm by inheritance. The supported coefficients have to
   * match the level of Hilbert space.
   *
   * @author Christian Scheiblich (cscheiblich@gmail.com)
   * @date 22.03.2015 13:01:47
   * @param spcHilb
   *          coefficients of 3-D frequency or Hilbert domain
   * @return coefficients of 3-D time domain
   * @throws JWaveException
   */
  public double[ ][ ][ ] reverse( double[ ][ ][ ] spcHilb, int lvlP, int lvlQ,
      int lvlR ) throws JWaveException {

    int noOfRows = spcHilb.length; // first dimension
    int noOfCols = spcHilb[ 0 ].length; // second dimension
    int noOfHigh = spcHilb[ 0 ][ 0 ].length; // third dimension

    double[ ][ ][ ] spcTime = new double[ noOfRows ][ noOfCols ][ noOfHigh ];

    for( int i = 0; i < noOfRows; i++ ) {

      double[ ][ ] matHilb = new double[ noOfCols ][ noOfHigh ];

      for( int j = 0; j < noOfCols; j++ ) {

        for( int k = 0; k < noOfHigh; k++ ) {

          matHilb[ j ][ k ] = spcHilb[ i ][ j ][ k ];

        } // high

      } // cols

      double[ ][ ] matTime = reverse( matHilb, lvlP, lvlQ ); // 2-D reverse

      for( int j = 0; j < noOfCols; j++ ) {

        for( int k = 0; k < noOfHigh; k++ ) {

          spcTime[ i ][ j ][ k ] = matTime[ j ][ k ];

        } // high

      } // cols

    } // rows

    for( int j = 0; j < noOfCols; j++ ) {

      for( int k = 0; k < noOfHigh; k++ ) {

        double[ ] arrHilb = new double[ noOfRows ];

        for( int i = 0; i < noOfRows; i++ )
          arrHilb[ i ] = spcTime[ i ][ j ][ k ];

        double[ ] arrTime = reverse( arrHilb, lvlR ); // 1-D reverse

        for( int i = 0; i < noOfRows; i++ )
          spcTime[ i ][ j ][ k ] = arrTime[ i ];

      } // high

    } // cols

    return spcTime;

  } // reverse

  /**
   * Returns true if given integer is of type binary (2, 4, 8, 16, ..) else the
   * method returns false.
   *
   * @author Christian Scheiblich (cscheiblich@gmail.com)
   * @date 22.03.2015 13:31:39
   * @param number
   *          an integer of type 2, 4, 8, 16, 32, 64, ...
   * @return true if number is a binary number else false
   */
  protected boolean isBinary( int number ) {

    return MathToolKit.isBinary( number ); // use MathToolKit or implement

  } // isBinary

  /**
   * Return the exponent of a binary a number
   *
   * @author Christian Scheiblich (cscheiblich@gmail.com)
   * @date 22.03.2015 13:35:50
   * @param number
   *          any integer that fulfills 2^p | p€N
   * @return p as number = 2^p | p€N
   * @throws JWaveException
   *           if given number is not a binary number
   */
  protected int calcExponent( int number ) throws JWaveException {

    if( !isBinary( number ) )
      throw new JWaveFailure( "BasicTransform#calcExponent - "
          + "given number is not binary: "
          + "2^p | p€N .. = 1, 2, 4, 8, 16, 32, .. " );

    return (int)( MathToolKit.getExponent( (int)( number ) ) ); // use MathToolKit or implement

  } // calcExponent

} // BasicTransform


text:
module PassengerRailsServer
  VERSION = "0.1"
end

redpajama_set_name: RedPajamaGithub


text:
package com.adioss.security;

public class SignatureSUNConstant {
    // Provider: SUN, SunEC, SunJSSE, SunRsaSign, SunMSCAPI
    public static final String MD2withRSA = "MD2withRSA";
    public static final String MD5andSHA1withRSA = "MD5andSHA1withRSA";
    public static final String MD5withRSA = "MD5withRSA";
    public static final String NONEwithDSA = "NONEwithDSA";
    public static final String NONEwithECDSA = "NONEwithECDSA";
    public static final String NONEwithRSA = "NONEwithRSA";
    public static final String SHA1withECDSA = "SHA1withECDSA";
    public static final String SHA1withDSA = "SHA1withDSA";
    public static final String SHA1withRSA = "SHA1withRSA";
    public static final String SHA224withDSA = "SHA224withDSA";
    public static final String SHA224withECDSA = "SHA224withECDSA";
    public static final String SHA224withRSA = "SHA224withRSA";
    public static final String SHA256withDSA = "SHA256withDSA";
    public static final String SHA256withECDSA = "SHA256withECDSA";
    public static final String SHA256withRSA = "SHA256withRSA";
    public static final String SHA384withECDSA = "SHA384withECDSA";
    public static final String SHA384withRSA = "SHA384withRSA";
    public static final String SHA512withECDSA = "SHA512withECDSA";
    public static final String SHA512withRSA = "SHA512withRSA";

    private SignatureSUNConstant() {
    }
}


text:
#include "Graphics/Graphics.h"

// Color
WORD_VAL    _color;

// Clipping region control
SHORT       _clipRgn;

// Clipping region borders
SHORT       _clipLeft;
SHORT       _clipTop;
SHORT       _clipRight;
SHORT       _clipBottom;

/////////////////////// LOCAL FUNCTIONS PROTOTYPES ////////////////////////////
void        PutImage1BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch);
void        PutImage4BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch);
void        PutImage8BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch);
void        PutImage16BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch);

void        PutImage1BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch);
void        PutImage4BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch);
void        PutImage8BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch);
void        PutImage16BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch);

/*********************************************************************
* Function:  SetAddress(addr2,addr1,addr0)
*
* PreCondition: none
*
* Input: addr0,addr1,addr2 - address bytes
*
* Output: none
*
* Side Effects: none
*
* Overview: writes S6D0129 address pointer
*
* Note: none
*
********************************************************************/
inline void SetAddress(DWORD address)
{
    DisplaySetCommand();
    DeviceWrite(SET_DATA_POINTER);
	DisplaySetData();
    DeviceWrite(((DWORD_VAL)address).v[0]);
    DeviceWrite(((DWORD_VAL)address).v[1]);
    DeviceWrite(((DWORD_VAL)address).v[2]);
}

/*********************************************************************
* Function:  void ResetDevice()
*
* PreCondition: none
*
* Input: none
*
* Output: none
*
* Side Effects: none
*
* Overview: resets LCD, initializes PMP
*
* Note: none
*
********************************************************************/
void ResetDevice(void)
{
	// Initialize the device
	DeviceInit();

	// Enable LCD
    DisplayEnable();

    DelayMs(10);

    // Clear text layer
    SetAddress(0);
    for(counter = 0; counter < 0x4b0; counter++)
    {
        DeviceWrite(0x07);
		DeviceWrite(0x07);
    }

    // Disable LCD
    DisplayDisable();

    DelayMs(20);
}

/*********************************************************************
* Function:  void SetColor(WORD color)
*
* PreCondition: none
*
* Input: color coded in format:
*           bits 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
*          color  R  R  R  R  R  G  G  G  G  G  G  B  B  B  B  B
*
* Output: none
*
* Side Effects: none
*
* Overview: sets current color
*
* Note: none
*
********************************************************************/
void SetColor(WORD color)
{
    _color.v[0] = ((WORD_VAL) color).v[0] & 0x1c;
    _color.v[1] = (((WORD_VAL) color).v[1] >> 1) & 0x73;
}

/*********************************************************************
* Function: void PutPixel(SHORT x, SHORT y)
*
* PreCondition: none
*
* Input: x,y - pixel coordinates
*
* Output: none
*
* Side Effects: none
*
* Overview: puts pixel
*
* Note: none
*
********************************************************************/
void PutPixel(SHORT x, SHORT y)
{
    DWORD   address;
    if(_clipRgn)
    {
        if(x < _clipLeft)
            return;
        if(x > _clipRight)
            return;
        if(y < _clipTop)
            return;
        if(y > _clipBottom)
            return;
    }

    DisplayEnable();
    address = BUF_MEM_OFFSET + (long)LINE_MEM_PITCH * y + x;
    SetAddress(address);
	DeviceWrite(_color.v[0]);
    DeviceWrite(_color.v[1]);
    DisplayDisable();
}

/*********************************************************************
* Function: WORD Bar(SHORT left, SHORT top, SHORT right, SHORT bottom)
*
* PreCondition: none
*
* Input: left,top - top left corner coordinates,
*        right,bottom - bottom right corner coordinates
*
* Output: For NON-Blocking configuration:
*         - Returns 0 when device is busy and the shape is not yet completely drawn.
*         - Returns 1 when the shape is completely drawn.
*         For Blocking configuration:
*         - Always return 1.
*
* Side Effects: none
*
* Overview: draws rectangle filled with current color
*
* Note: none
*
********************************************************************/
WORD Bar(SHORT left, SHORT top, SHORT right, SHORT bottom)
{
    DWORD       address;
    register SHORT  x, y;

    #ifndef USE_NONBLOCKING_CONFIG
    while(IsDeviceBusy() != 0);

    /* Ready */
    #else
    if(IsDeviceBusy() != 0)
        return (0);
    #endif
    if(_clipRgn)
    {
        if(left < _clipLeft)
            left = _clipLeft;
        if(right > _clipRight)
            right = _clipRight;
        if(top < _clipTop)
            top = _clipTop;
        if(bottom > _clipBottom)
            bottom = _clipBottom;
    }

    address = BUF_MEM_OFFSET + (DWORD) LINE_MEM_PITCH * top + left;

    DisplayEnable();

    for(y = top; y < bottom + 1; y++)
    {
        SetAddress(address);
        for(x = left; x < right + 1; x++)
        {
            DeviceWrite(_color.v[1]);
			DeviceWrite(_color.v[0]);
        }

        address += LINE_MEM_PITCH;
    }

    DisplayDisable();
    return (1);
}

/*********************************************************************
* Function: void ClearDevice(void)
*
* PreCondition: none
*
* Input: none
*
* Output: none
*
* Side Effects: none
*
* Overview: clears screen with current color
*
* Note: none
*
********************************************************************/
void ClearDevice(void)
{
    DWORD   counter;

    DisplayEnable();
    SetAddress(0x018000);
    for(counter = 0; counter < (DWORD) (GetMaxX() + 1) * (GetMaxY() + 1); counter++)
    {
        DeviceWrite(_color.v[1]);
		DeviceWrite(_color.v[0]);
    }

    DisplayDisable();
    MoveTo(0, 0);
}

/*********************************************************************
* Function: WORD PutImage(SHORT left, SHORT top, void* bitmap, BYTE stretch)
*
* PreCondition: none
*
* Input: left,top - left top image corner, bitmap - image pointer,
*        stretch - image stretch factor
*
* Output: For NON-Blocking configuration:
*         - Returns 0 when device is busy and the image is not yet completely drawn.
*         - Returns 1 when the image is completely drawn.
*         For Blocking configuration:
*         - Always return 1.
*
* Side Effects: none
*
* Overview: outputs image starting from left,top coordinates
*
* Note: image must be located in flash
*
********************************************************************/
WORD PutImage(SHORT left, SHORT top, void *bitmap, BYTE stretch)
{
    FLASH_BYTE  *flashAddress;
    BYTE        colorDepth;
    WORD        colorTemp;

    #ifndef USE_NONBLOCKING_CONFIG
    while(IsDeviceBusy() != 0);

    /* Ready */
    #else
    if(IsDeviceBusy() != 0)
        return (0);
    #endif

    // Save current color
    colorTemp = _color.Val;

    switch(*((SHORT *)bitmap))
    {
            #ifdef USE_BITMAP_FLASH

        case FLASH:

            // Image address
            flashAddress = ((BITMAP_FLASH *)bitmap)->address;

            // Read color depth
            colorDepth = *(flashAddress + 1);

            // Draw picture
            switch(colorDepth)
            {
                case 1:     PutImage1BPP(left, top, flashAddress, stretch); break;
                case 4:     PutImage4BPP(left, top, flashAddress, stretch); break;
                case 8:     PutImage8BPP(left, top, flashAddress, stretch); break;
                case 16:    PutImage16BPP(left, top, flashAddress, stretch); break;
            }

            break;
            #endif
            #ifdef USE_BITMAP_EXTERNAL

        case EXTERNAL:

            // Get color depth
            ExternalMemoryCallback(bitmap, 1, 1, &colorDepth);

            // Draw picture
            switch(colorDepth)
            {
                case 1:     PutImage1BPPExt(left, top, bitmap, stretch); break;
                case 4:     PutImage4BPPExt(left, top, bitmap, stretch); break;
                case 8:     PutImage8BPPExt(left, top, bitmap, stretch); break;
                case 16:    PutImage16BPPExt(left, top, bitmap, stretch); break;
                default:    break;
            }

            break;
            #endif

        default:
            break;
    }

    // Restore current color
    _color.Val = colorTemp;
    return (1);
}

#ifdef USE_BITMAP_FLASH

/*********************************************************************
* Function: void PutImage1BPP(SHORT left, SHORT top, FLASH_BYTE* bitmap, BYTE stretch)
*
* PreCondition: none
*
* Input: left,top - left top image corner, bitmap - image pointer,
*        stretch - image stretch factor
*
* Output: none
*
* Side Effects: none
*
* Overview: outputs monochrome image starting from left,top coordinates
*
* Note: image must be located in flash
*
********************************************************************/
void PutImage1BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch)
{
    register FLASH_BYTE *flashAddress;
    register FLASH_BYTE *tempFlashAddress;
    register DWORD  address;
    BYTE                temp;
    register WORD       sizeX, sizeY;
    WORD                x, y;
    register BYTE       stretchX, stretchY;
    WORD                pallete[2];
    BYTE                mask;

    // Move pointer to size information
    flashAddress = bitmap + 2;

    // Set start address
    address = BUF_MEM_OFFSET + (long)LINE_MEM_PITCH * top + left;

    // Read image size
    sizeY = *((FLASH_WORD *)flashAddress);
    flashAddress += 2;
    sizeX = *((FLASH_WORD *)flashAddress);
    flashAddress += 2;
    pallete[0] = *((FLASH_WORD *)flashAddress);
    flashAddress += 2;
    pallete[1] = *((FLASH_WORD *)flashAddress);
    flashAddress += 2;

    for(y = 0; y < sizeY; y++)
    {
        tempFlashAddress = flashAddress;
		DisplayEnable();
        for(stretchY = 0; stretchY < stretch; stretchY++)
        {
            flashAddress = tempFlashAddress;
            SetAddress(address);
            mask = 0;
            for(x = 0; x < sizeX; x++)
            {

                // Read 8 pixels from flash
                if(mask == 0)
                {
                    temp = *flashAddress;
                    flashAddress++;
                    mask = 0x80;
                }

                // Set color
                if(mask & temp)
                {
                    SetColor(pallete[1]);
                }
                else
                {
                    SetColor(pallete[0]);
                }

                // Write pixel to screen
                for(stretchX = 0; stretchX < stretch; stretchX++)
                {
                    DeviceWrite(_color.v[1]);
					DeviceWrite(_color.v[0]);
                }

                // Shift to the next pixel
                mask >>= 1;
            }

            address += LINE_MEM_PITCH;
        }
    }

    DisplayDisable();
}

/*********************************************************************
* Function: void PutImage4BPP(SHORT left, SHORT top, FLASH_BYTE* bitmap, BYTE stretch)
*
* PreCondition: none
*
* Input: left,top - left top image corner, bitmap - image pointer,
*        stretch - image stretch factor
*
* Output: none
*
* Side Effects: none
*
* Overview: outputs 16 color image starting from left,top coordinates
*
* Note: image must be located in flash
*
********************************************************************/
void PutImage4BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch)
{
    register DWORD  address;
    register FLASH_BYTE *flashAddress;
    register FLASH_BYTE *tempFlashAddress;
    WORD                sizeX, sizeY;
    register WORD       x, y;
    BYTE                temp;
    register BYTE       stretchX, stretchY;
    WORD                pallete[16];
    WORD                counter;

    // Move pointer to size information
    flashAddress = bitmap + 2;

    // Set start address
    address = BUF_MEM_OFFSET + (long)LINE_MEM_PITCH * top + left;

    // Read image size
    sizeY = *((FLASH_WORD *)flashAddress);
    flashAddress += 2;
    sizeX = *((FLASH_WORD *)flashAddress);
    flashAddress += 2;

    // Read pallete
    for(counter = 0; counter < 16; counter++)
    {
        pallete[counter] = *((FLASH_WORD *)flashAddress);
        flashAddress += 2;
    }

    for(y = 0; y < sizeY; y++)
    {
        tempFlashAddress = flashAddress;
        for(stretchY = 0; stretchY < stretch; stretchY++)
        {
			DisplayEnable();
            flashAddress = tempFlashAddress;
            SetAddress(address);
            for(x = 0; x < sizeX; x++)
            {

                // Read 2 pixels from flash
                if((x & 0x0001) == 0)
                {
                    temp = *flashAddress;
                    flashAddress++;
                }

                // Set color
                SetColor(pallete[temp & 0x0f]);

                // Write pixel to screen
                for(stretchX = 0; stretchX < stretch; stretchX++)
                {
                    DeviceWrite(_color.v[1]);
					DeviceWrite(_color.v[0]);
                }

                // Shift to the next pixel
                temp >>= 4;
            }

            address += LINE_MEM_PITCH;
			DisplayDisable();
        }
    }

}

/*********************************************************************
* Function: void PutImage8BPP(SHORT left, SHORT top, FLASH_BYTE* bitmap, BYTE stretch)
*
* PreCondition: none
*
* Input: left,top - left top image corner, bitmap - image pointer,
*        stretch - image stretch factor
*
* Output: none
*
* Side Effects: none
*
* Overview: outputs 256 color image starting from left,top coordinates
*
* Note: image must be located in flash
*
********************************************************************/
void PutImage8BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch)
{
    register DWORD  address;
    register FLASH_BYTE *flashAddress;
    register FLASH_BYTE *tempFlashAddress;
    WORD                sizeX, sizeY;
    register WORD       x, y;
    BYTE                temp;
    register BYTE       stretchX, stretchY;
    WORD                pallete[256];
    WORD                counter;

    // Move pointer to size information
    flashAddress = bitmap + 2;

    // Set start address
    address = BUF_MEM_OFFSET + (long)LINE_MEM_PITCH * top + left;

    // Read image size
    sizeY = *((FLASH_WORD *)flashAddress);
    flashAddress += 2;
    sizeX = *((FLASH_WORD *)flashAddress);
    flashAddress += 2;

    // Read pallete
    for(counter = 0; counter < 256; counter++)
    {
        pallete[counter] = *((FLASH_WORD *)flashAddress);
        flashAddress += 2;
    }

    DisplayEnable();
    for(y = 0; y < sizeY; y++)
    {
        tempFlashAddress = flashAddress;
        for(stretchY = 0; stretchY < stretch; stretchY++)
        {
            flashAddress = tempFlashAddress;
            SetAddress(address);
            for(x = 0; x < sizeX; x++)
            {

                // Read pixels from flash
                temp = *flashAddress;
                flashAddress++;

                // Set color
                SetColor(pallete[temp]);

                // Write pixel to screen
                for(stretchX = 0; stretchX < stretch; stretchX++)
                {
                    DeviceWrite(_color.v[1]);
					DeviceWrite(_color.v[0]);
                }
            }

            address += LINE_MEM_PITCH;
        }
    }

    DisplayDisable();
}

/*********************************************************************
* Function: void PutImage16BPP(SHORT left, SHORT top, FLASH_BYTE* bitmap, BYTE stretch)
*
* PreCondition: none
*
* Input: left,top - left top image corner, bitmap - image pointer,
*        stretch - image stretch factor
*
* Output: none
*
* Side Effects: none
*
* Overview: outputs hicolor image starting from left,top coordinates
*
* Note: image must be located in flash
*
********************************************************************/
void PutImage16BPP(SHORT left, SHORT top, FLASH_BYTE *bitmap, BYTE stretch)
{
    register DWORD  address;
    register FLASH_WORD *flashAddress;
    register FLASH_WORD *tempFlashAddress;
    WORD                sizeX, sizeY;
    register WORD       x, y;
    WORD                temp;
    register BYTE       stretchX, stretchY;

    // Move pointer to size information
    flashAddress = (FLASH_WORD *)bitmap + 1;

    // Set start address
    address.Val = BUF_MEM_OFFSET + (long)LINE_MEM_PITCH * top + left;

    // Read image size
    sizeY = *flashAddress;
    flashAddress++;
    sizeX = *flashAddress;
    flashAddress++;

    DisplayEnable();
    for(y = 0; y < sizeY; y++)
    {
        tempFlashAddress = flashAddress;
        for(stretchY = 0; stretchY < stretch; stretchY++)
        {
            flashAddress = tempFlashAddress;
            SetAddress(address);
            for(x = 0; x < sizeX; x++)
            {

                // Read pixels from flash
                temp = *flashAddress;
                flashAddress++;

                // Set color
                SetColor(temp);

                // Write pixel to screen
                for(stretchX = 0; stretchX < stretch; stretchX++)
                {
                    DeviceWrite(_color.v[1]);
					DeviceWrite(_color.v[0]);
                }
            }

            address += LINE_MEM_PITCH;
        }
    }

    DisplayDisable();
}

#endif
#ifdef USE_BITMAP_EXTERNAL

/*********************************************************************
* Function: void PutImage1BPPExt(SHORT left, SHORT top, void* bitmap, BYTE stretch)
*
* PreCondition: none
*
* Input: left,top - left top image corner, bitmap - image pointer,
*        stretch - image stretch factor
*
* Output: none
*
* Side Effects: none
*
* Overview: outputs monochrome image starting from left,top coordinates
*
* Note: image must be located in flash
*
********************************************************************/
void PutImage1BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch)
{
    register DWORD      address;
    register DWORD      memOffset;
    BITMAP_HEADER       bmp;
    WORD                pallete[2];
    BYTE                lineBuffer[320 / 8];
    BYTE                *pData;
    SHORT               byteWidth;

    BYTE                temp;
    BYTE                mask;
    WORD                sizeX, sizeY;
    WORD                x, y;
    BYTE                stretchX, stretchY;

    // Set start address
    address = BUF_MEM_OFFSET + (long)LINE_MEM_PITCH * top + left;

    // Get bitmap header
    ExternalMemoryCallback(bitmap, 0, sizeof(BITMAP_HEADER), &bmp);

    // Get pallete (2 entries)
    ExternalMemoryCallback(bitmap, sizeof(BITMAP_HEADER), 2 * sizeof(WORD), pallete);

    // Set offset to the image data
    memOffset = sizeof(BITMAP_HEADER) + 2 * sizeof(WORD);

    // Line width in bytes
    byteWidth = bmp.width >> 3;
    if(bmp.width & 0x0007)
        byteWidth++;

    // Get size
    sizeX = bmp.width;
    sizeY = bmp.height;

    DisplayEnable();
    for(y = 0; y < sizeY; y++)
    {

        // Get line
        ExternalMemoryCallback(bitmap, memOffset, byteWidth, lineBuffer);
        memOffset += byteWidth;

        for(stretchY = 0; stretchY < stretch; stretchY++)
        {
            pData = lineBuffer;
            SetAddress(address);
            mask = 0;
            for(x = 0; x < sizeX; x++)
            {

                // Read 8 pixels from flash
                if(mask == 0)
                {
                    temp = *pData++;
                    mask = 0x80;
                }

                // Set color
                if(mask & temp)
                {
                    SetColor(pallete[1]);
                }
                else
                {
                    SetColor(pallete[0]);
                }

                // Write pixel to screen
                for(stretchX = 0; stretchX < stretch; stretchX++)
                {
                    DeviceWrite(_color.v[1]);
					DeviceWrite(_color.v[0]);
                }

                // Shift to the next pixel
                mask >>= 1;
            }

            address += LINE_MEM_PITCH;
        }
    }

    DisplayDisable();
}

/*********************************************************************
* Function: void PutImage4BPPExt(SHORT left, SHORT top, void* bitmap, BYTE stretch)
*
* PreCondition: none
*
* Input: left,top - left top image corner, bitmap - image pointer,
*        stretch - image stretch factor
*
* Output: none
*
* Side Effects: none
*
* Overview: outputs monochrome image starting from left,top coordinates
*
* Note: image must be located in flash
*
********************************************************************/
void PutImage4BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch)
{
    register DWORD      address;
    register DWORD      memOffset;
    BITMAP_HEADER       bmp;
    WORD                pallete[16];
    BYTE                lineBuffer[320 / 2];
    BYTE                *pData;
    SHORT               byteWidth;

    BYTE                temp;
    WORD                sizeX, sizeY;
    WORD                x, y;
    BYTE                stretchX, stretchY;

    // Set start address
    address = BUF_MEM_OFFSET + (long)LINE_MEM_PITCH * top + left;

    // Get bitmap header
    ExternalMemoryCallback(bitmap, 0, sizeof(BITMAP_HEADER), &bmp);

    // Get pallete (16 entries)
    ExternalMemoryCallback(bitmap, sizeof(BITMAP_HEADER), 16 * sizeof(WORD), pallete);

    // Set offset to the image data
    memOffset = sizeof(BITMAP_HEADER) + 16 * sizeof(WORD);

    // Line width in bytes
    byteWidth = bmp.width >> 1;
    if(bmp.width & 0x0001)
        byteWidth++;

    // Get size
    sizeX = bmp.width;
    sizeY = bmp.height;

    for(y = 0; y < sizeY; y++)
    {

        // Get line
        ExternalMemoryCallback(bitmap, memOffset, byteWidth, lineBuffer);
        memOffset += byteWidth;
        DisplayEnable();
        for(stretchY = 0; stretchY < stretch; stretchY++)
        {
            pData = lineBuffer;
            SetAddress(address);

            for(x = 0; x < sizeX; x++)
            {

                // Read 2 pixels from flash
                if(x & 0x0001)
                {

                    // second pixel in byte
                    SetColor(pallete[temp & 0x0f]);
                }
                else
                {
                    temp = *pData++;

                    // first pixel in byte
                    SetColor(pallete[temp >> 4]);
                }

                // Write pixel to screen
                for(stretchX = 0; stretchX < stretch; stretchX++)
                {
                    DeviceWrite(_color.v[1]);
					DeviceWrite(_color.v[0]);
                }
            }

            address += LINE_MEM_PITCH;
        }

        DisplayDisable();
    }
}

/*********************************************************************
* Function: void PutImage8BPPExt(SHORT left, SHORT top, void* bitmap, BYTE stretch)
*
* PreCondition: none
*
* Input: left,top - left top image corner, bitmap - image pointer,
*        stretch - image stretch factor
*
* Output: none
*
* Side Effects: none
*
* Overview: outputs monochrome image starting from left,top coordinates
*
* Note: image must be located in flash
*
********************************************************************/
void PutImage8BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch)
{
    register DWORD      address;
    register DWORD      memOffset;
    BITMAP_HEADER       bmp;
    WORD                pallete[256];
    BYTE                lineBuffer[320];
    BYTE                *pData;

    BYTE                temp;
    WORD                sizeX, sizeY;
    WORD                x, y;
    BYTE                stretchX, stretchY;

    // Set start address
    address = BUF_MEM_OFFSET + (long)LINE_MEM_PITCH * top + left;

    // Get bitmap header
    ExternalMemoryCallback(bitmap, 0, sizeof(BITMAP_HEADER), &bmp);

    // Get pallete (256 entries)
    ExternalMemoryCallback(bitmap, sizeof(BITMAP_HEADER), 256 * sizeof(WORD), pallete);

    // Set offset to the image data
    memOffset = sizeof(BITMAP_HEADER) + 256 * sizeof(WORD);

    // Get size
    sizeX = bmp.width;
    sizeY = bmp.height;

    for(y = 0; y < sizeY; y++)
    {

        // Get line
        ExternalMemoryCallback(bitmap, memOffset, sizeX, lineBuffer);
        memOffset += sizeX;

        DisplayEnable();

        for(stretchY = 0; stretchY < stretch; stretchY++)
        {
            pData = lineBuffer;
            SetAddress(address);

            for(x = 0; x < sizeX; x++)
            {
                temp = *pData++;
                SetColor(pallete[temp]);

                // Write pixel to screen
                for(stretchX = 0; stretchX < stretch; stretchX++)
                {
                    DeviceWrite(_color.v[1]);
					DeviceWrite(_color.v[0]);
                }
            }

            address += LINE_MEM_PITCH;
        }

        DisplayDisable();
    }
}

/*********************************************************************
* Function: void PutImage8BPPExt(SHORT left, SHORT top, void* bitmap, BYTE stretch)
*
* PreCondition: none
*
* Input: left,top - left top image corner, bitmap - image pointer,
*        stretch - image stretch factor
*
* Output: none
*
* Side Effects: none
*
* Overview: outputs monochrome image starting from left,top coordinates
*
* Note: image must be located in flash
*
********************************************************************/
void PutImage16BPPExt(SHORT left, SHORT top, void *bitmap, BYTE stretch)
{
    register DWORD  address;
    register DWORD      memOffset;
    BITMAP_HEADER       bmp;
    WORD                lineBuffer[320];
    WORD                *pData;
    WORD                byteWidth;

    WORD                temp;
    WORD                sizeX, sizeY;
    WORD                x, y;
    BYTE                stretchX, stretchY;

    // Set start address
    address = BUF_MEM_OFFSET + (long)LINE_MEM_PITCH * top + left;

    // Get bitmap header
    ExternalMemoryCallback(bitmap, 0, sizeof(BITMAP_HEADER), &bmp);

    // Set offset to the image data
    memOffset = sizeof(BITMAP_HEADER);

    // Get size
    sizeX = bmp.width;
    sizeY = bmp.height;

    byteWidth = sizeX << 1;

    for(y = 0; y < sizeY; y++)
    {

        // Get line
        ExternalMemoryCallback(bitmap, memOffset, byteWidth, lineBuffer);
        memOffset += byteWidth;

        DisplayEnable();

        for(stretchY = 0; stretchY < stretch; stretchY++)
        {
            pData = lineBuffer;
            SetAddress(address);

            for(x = 0; x < sizeX; x++)
            {
                temp = *pData++;
                SetColor(temp);

                // Write pixel to screen
                for(stretchX = 0; stretchX < stretch; stretchX++)
                {
                    DeviceWrite(_color.v[1]);
					DeviceWrite(_color.v[0]);
                }
            }

            address += LINE_MEM_PITCH;
        }

        DisplayDisable();
    }
}

#endif


text:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.redkale.test.convert;

import java.io.*;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.redkale.convert.bson.BsonByteBufferWriter;
import org.redkale.convert.bson.BsonFactory;
import org.redkale.util.Utility;
import org.redkale.convert.bson.BsonConvert;

import java.nio.*;
import java.util.*;
import javax.persistence.*;

import org.redkale.convert.json.*;
import org.redkale.util.*;

/**
 * @author zhangjx
 */
public class BsonMainTest {

    @Test
    public void run1() throws Throwable {
        Serializable[] sers = new Serializable[]{"aaa", 4};
        final BsonConvert convert = BsonFactory.root().getConvert();
        byte[] bytes = convert.convertTo(sers);
        Utility.println("---", bytes);
        byte[] checks = new byte[]{0x00, 0x00, 0x00, 0x02, 0x7f, 0x01, 0x41, 0x00, 0x00, 0x00, 0x03, 0x61, 0x61, 0x61, 0x01, 0x69, 0x00, 0x00, 0x00, 0x04};
        Assertions.assertArrayEquals(checks, bytes);
        Serializable[] a = convert.convertFrom(Serializable[].class, bytes);
        Assertions.assertEquals("[aaa, 4]", Arrays.toString(a));
    }

    @Test
    public void run2() throws Exception {
        final BsonConvert convert = BsonFactory.root().getConvert();
        SimpleChildEntity entry = SimpleChildEntity.create();
        byte[] bytes = convert.convertTo(SimpleEntity.class, entry);
        System.out.println("长度: " + bytes.length);
        Assertions.assertEquals(260, bytes.length);
        BsonByteBufferWriter writer = convert.pollBsonWriter(() -> ByteBuffer.allocate(1));
        convert.convertTo(writer, SimpleEntity.class, entry);
        ByteBuffer[] buffers = writer.toBuffers();
        int len = 0;
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        for (ByteBuffer b : buffers) {
            len += b.remaining();
            byte[] ts = new byte[b.remaining()];
            b.get(ts);
            out.write(ts);
            b.flip();
        }
        System.out.println("长度: " + len);
        Assertions.assertEquals(260, len);
        SimpleChildEntity entry2 = convert.convertFrom(SimpleChildEntity.class, buffers);
        System.out.println(entry);
        Assertions.assertEquals(entry.toString(), entry2.toString());
    }

    @Test
    public void run3() throws Exception {
        final BsonConvert convert = BsonFactory.root().getConvert();
        SimpleChildEntity entry = SimpleChildEntity.create();
        byte[] bytes = convert.convertTo(SimpleEntity.class, entry);
        Utility.println(null, bytes);
        System.out.println(JsonConvert.root().convertTo(entry));
        SimpleEntity rs = convert.convertFrom(SimpleEntity.class, bytes);
        Assertions.assertEquals(JsonConvert.root().convertTo(entry), rs.toString());

        ComplextEntity bean = new ComplextEntity();
        byte[] bytes2 = convert.convertTo(Object.class, bean);
        final int len = bytes2.length;
        BsonByteBufferWriter writer = convert.pollBsonWriter(() -> ByteBuffer.allocate(len / 2));
        convert.convertTo(writer, bean);
        bytes2 = writer.toArray();
        System.out.println(convert.convertFrom(ComplextEntity.class, bytes2).toString());
        Assertions.assertEquals("{\"flag\":true,\"userid\":0}", convert.convertFrom(ComplextEntity.class, bytes2).toString());
    }

    @Test
    public void run4() throws Exception {
        final BsonConvert convert = BsonFactory.root().getConvert();
        SimpleChildEntity entry = SimpleChildEntity.create();
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        convert.convertTo(out, SimpleEntity.class, entry);
        byte[] bytes = out.toByteArray();
        Utility.println(null, bytes);
        SimpleEntity rs = convert.convertFrom(SimpleEntity.class, new ByteArrayInputStream(bytes));
        System.out.println(rs.toString());
        Assertions.assertEquals(JsonConvert.root().convertTo(entry), rs.toString());
    }

    @Test
    public void run5() throws Exception {
        final BsonConvert convert = BsonFactory.root().getConvert();

        LinkedHashMap map = new LinkedHashMap();
        map.put("1", 1);
        map.put("2", "a2");
        byte[] bs = convert.convertTo(Object.class, map);
        Object mapobj = convert.convertFrom(Object.class, bs);
        System.out.println(mapobj);
        Assertions.assertEquals("{1=1, 2=a2}", mapobj.toString());
    }

    @Test
    public void run6() throws Exception {
        final BsonConvert convert = BsonFactory.root().getConvert();

        Optional<String> val = Optional.ofNullable("haha");
        byte[] bs = convert.convertTo(val);
        Object obj = convert.convertFrom(Optional.class, bs);
        System.out.println(obj);
        Assertions.assertEquals("Optional[haha]", obj.toString());
        bs = convert.convertTo(Object.class, val);
        obj = convert.convertFrom(Object.class, bs);
        Assertions.assertEquals("Optional[haha]", obj.toString());
        bs = convert.convertTo(new TypeToken<Optional<String>>() {
        }.getType(), val);
        obj = convert.convertFrom(new TypeToken<Optional<String>>() {
        }.getType(), bs);
        Assertions.assertEquals("Optional[haha]", obj.toString());
        System.out.println(JsonConvert.root().convertTo(val));
        Assertions.assertEquals("\"haha\"", JsonConvert.root().convertTo(val));
    }

    @Test
    public void run7() throws Throwable {
        Two two = new Two();
        two.setKey("key111");
        two.setCode(12345);
        List<String> list = new ArrayList<>();
        list.add("haha");
        two.setList(list);
        Map<String, String> map = new HashMap<>();
        map.put("222", "333");
        two.setStringMap(map);

        List<ConvertRecord> records = new ArrayList<>();
        records.add(ConvertRecord.createDefault());
        two.setRecords(records);

        Map<String, ConvertRecord> rmap = new HashMap<>();
        rmap.put("222", ConvertRecord.createDefault());
        two.setRecordMap(rmap);

        byte[] bs = BsonFactory.root().getConvert().convertTo(two);

        One one = BsonFactory.root().getConvert().convertFrom(One.class, bs);
        System.out.println(one);
        Assertions.assertEquals("{\"bytes\":[3,4,5],\"code\":12345,\"ints\":[3000,4000,5000],\"key\":\"key111\"}", one.toString());
    }

    @Test
    public void run8() throws Exception {
        final JsonConvert jsonConvert = JsonConvert.root();
        final BsonConvert bsonConvert = BsonFactory.root().getConvert();
        ConstructorArgsEntity bean = new ConstructorArgsEntity(12345678, "哈哈");
        bean.setCreatetime(12345678901L);
        String json = jsonConvert.convertTo(bean);
        System.out.println(json);
        Assertions.assertEquals("{\"createtime\":12345678901,\"name\":\"哈哈\",\"userid\":12345678}", json);
        Assertions.assertEquals(jsonConvert.convertFrom(ConstructorArgsEntity.class, json).toString(), json);
        byte[] bytes = bsonConvert.convertTo(bean);
        Assertions.assertEquals(bsonConvert.convertFrom(ConstructorArgsEntity.class, bytes).toString(), json);
    }

    public static class ComplextEntity {

        @Id
        private int userid;

        private String chname = "";

        @Transient
        private boolean flag = true;

        @Transient
        private List<SimpleChildEntity> children;

        @Transient
        private SimpleEntity user;

        public int getUserid() {
            return userid;
        }

        public void setUserid(int userid) {
            this.userid = userid;
        }

        public String getChname() {
            return chname;
        }

        public void setChname(String chname) {
            this.chname = chname;
        }

        public boolean isFlag() {
            return flag;
        }

        public void setFlag(boolean flag) {
            this.flag = flag;
        }

        public List<SimpleChildEntity> getChildren() {
            return children;
        }

        public void setChildren(List<SimpleChildEntity> children) {
            this.children = children;
        }

        public SimpleEntity getUser() {
            return user;
        }

        public void setUser(SimpleEntity user) {
            this.user = user;
        }

        @Override
        public String toString() {
            return JsonConvert.root().convertTo(this);
        }
    }

    public static class ConstructorArgsEntity {

        private final int userid;

        private String name;

        private long createtime;

        @ConstructorParameters({"userid", "name"})
        public ConstructorArgsEntity(int userid, String name) {
            this.userid = userid;
            this.name = name;
        }

        public int getUserid() {
            return userid;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public long getCreatetime() {
            return createtime;
        }

        public void setCreatetime(long createtime) {
            this.createtime = createtime;
        }

        @Override
        public String toString() {
            return JsonConvert.root().convertTo(this);
        }
    }
}


text:
use crate::verifier::assume;

/// Create a non-deterministic value with the same type as the argument
///
/// The argument does not influence the result of the function.
///
/// This is intended to be compatible with SMACK
pub trait VerifierNonDet {
    fn verifier_nondet(self) -> Self;

    #[cfg(feature = "verifier-klee")]
    /// Obtain a concrete value satisfying the constraints
    /// currently in force for the expression.
    ///
    /// Not guaranteed to produce different (or the same) value
    /// if called repeatedly.
    /// (Use assumptions or if-statements to produce different results
    /// each time.)
    ///
    /// This function may not be implementable with other
    /// verifiers so it should be used with caution.
    fn get_concrete_value(x: Self) -> Self;

    #[cfg(feature = "verifier-klee")]
    /// Test whether a value is concrete or symbolic
    ///
    /// Values are guaranteed to be concrete if they are derived
    /// from concrete values, literal constants or
    /// calls to `get_concrete_value`.
    fn is_symbolic(x: Self) -> bool;
}

pub trait AbstractValue: Sized {
    /// Create an abstract value of type `Self`
    fn abstract_value() -> Self;

    /// Create an abstract value satisfying a predicate `F`
    fn abstract_where<F: FnOnce(&Self) -> bool>(f: F) -> Self {
        let x = Self::abstract_value();
        assume(f(&x));
        x
    }
}

/// Create a symbolic value of type `Self` and with
/// documentation name `desc`
///
/// This is intended to be compatible with Crux-MIR.
pub trait Symbolic: Sized {
    fn symbolic(desc: &'static str) -> Self;

    fn symbolic_where<F: FnOnce(&Self) -> bool>(desc: &'static str, f: F) -> Self {
        let x = Self::symbolic(desc);
        assume(f(&x));
        x
    }
}

/////////////////////////////////////////////////////////////////
// End
/////////////////////////////////////////////////////////////////


text:
/* @flow */
function garbageCollect(comment: Comment) {
  delete comment.context.code;
  delete comment.context.ast;
  return comment;
}

module.exports = garbageCollect;


text:
package com.sunteorum.novious.fragment;

import android.graphics.Bitmap;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.facebook.cache.common.CacheKey;
import com.facebook.common.references.CloseableReference;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.controller.BaseControllerListener;
import com.facebook.drawee.controller.ControllerListener;
import com.facebook.drawee.drawable.ScalingUtils;
import com.facebook.drawee.generic.GenericDraweeHierarchy;
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
import com.facebook.drawee.interfaces.DraweeController;
import com.facebook.imagepipeline.bitmaps.PlatformBitmapFactory;
import com.facebook.imagepipeline.request.ImageRequest;
import com.facebook.imagepipeline.request.ImageRequestBuilder;
import com.facebook.imagepipeline.request.Postprocessor;
import com.sunteorum.novious.R;
import com.sunteorum.novious.widget.GestureImageView;

/**
 * Created by KYO on 2015/8/9.
 */
public class MangaFragment extends Fragment {
	public static final String TAG = MangaFragment.class.getSimpleName();

	public static final String URL_ARGUMENT_KEY = TAG + ":" + "UrlArgumentKey";
	public static final String POSITION_ARGUMENT_KEY = TAG + ":" + "PositionArgumentKey";

	private GestureImageView mGestureImageView;

	private String mUrl;
	private int mPosition;

	public static MangaFragment newInstance(String url, int position) {
		MangaFragment newInstance = new MangaFragment();

		Bundle arguments = new Bundle();
		arguments.putString(URL_ARGUMENT_KEY, url);
		arguments.putInt(POSITION_ARGUMENT_KEY, position);
		newInstance.setArguments(arguments);

		return newInstance;
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		Bundle arguments = getArguments();
		if (arguments != null) {
			if (arguments.containsKey(URL_ARGUMENT_KEY)) {
				mUrl = arguments.getString(URL_ARGUMENT_KEY);
			}
			if (arguments.containsKey(POSITION_ARGUMENT_KEY)) {
				mPosition = arguments.getInt(POSITION_ARGUMENT_KEY);
			}
		}
	}

	@Override
	public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
		View pageView = inflater.inflate(R.layout.fragment_manga, container, false);

		mGestureImageView = (GestureImageView) pageView.findViewById(R.id.image);

		return pageView;
	}

	@Override
	public void onActivityCreated(@Nullable Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		mGestureImageView.setScaleType(ImageView.ScaleType.CENTER);

		Drawable placeHolderDrawable = getResources().getDrawable(R.mipmap.ic_image_white_48dp);
		placeHolderDrawable.setColorFilter(getResources().getColor(R.color.accent_pink_a200), PorterDuff.Mode.MULTIPLY);
		Drawable errorHolderDrawable = getResources().getDrawable(R.mipmap.ic_error_white_48dp);
		errorHolderDrawable.setColorFilter(getResources().getColor(R.color.accent_pink_a200), PorterDuff.Mode.MULTIPLY);

		GenericDraweeHierarchyBuilder builder =
				new GenericDraweeHierarchyBuilder(getResources());
		GenericDraweeHierarchy hierarchy = builder
				.setFadeDuration(300)
				.setPlaceholderImage(placeHolderDrawable) //占位图
				.setFailureImage(errorHolderDrawable) //设置加载失败占位图
				.setBackgrounds(null) //背景
				.setOverlays(null) //设置叠加图
				.setPressedStateOverlay(null) //设置按压状态下的叠加图
				//.setActualImageColorFilter(null)
				.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
				//.setActualImageFocusPoint(null)
				.build();

		//RoundingParams roundingParams = hierarchy.getRoundingParams();
		//roundingParams.setCornersRadius(10);
		//hierarchy.setRoundingParams(roundingParams);

		ControllerListener listener = new BaseControllerListener() {

			@Override
			public void onSubmit(String id, Object callerContext) {
				super.onSubmit(id, callerContext);
				mGestureImageView.initializeView();
			}
		};

		//后处理器:对获取的图片做些修改
		Postprocessor myPostprocessor = new Postprocessor() {

			@Override
			public CloseableReference<Bitmap> process(Bitmap bitmap, PlatformBitmapFactory platformBitmapFactory) {
				return null;
			}

			@Override
			public String getName() {
				return null;
			}

			@Override
			public CacheKey getPostprocessorCacheKey() {
				return null;
			}
		};

		ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(mUrl))
				.setPostprocessor(myPostprocessor)
				.setAutoRotateEnabled(true) //自动旋转
				.setProgressiveRenderingEnabled(true) //允许渐进式JPEG图片加载
				.build();

		DraweeController controller = Fresco.newDraweeControllerBuilder()
				.setImageRequest(request)
				.setTapToRetryEnabled(true) //点击重新加载图
				.setOldController(mGestureImageView.getController())
				.setControllerListener(listener)
				.build();

		mGestureImageView.setHierarchy(hierarchy);
		mGestureImageView.setController(controller);
		//mGestureImageView.setImageURI(uri);

	}

}


text:
package org.openweathermap.model;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

/**
 * Created by Mohsen on 03/01/2017.
 */

public class Main {

    @SerializedName("temp")
    @Expose
    private Double temp;
    @SerializedName("pressure")
    @Expose
    private Double pressure;
    @SerializedName("humidity")
    @Expose
    private Integer humidity;
    @SerializedName("temp_min")
    @Expose
    private Double tempMin;
    @SerializedName("temp_max")
    @Expose
    private Double tempMax;
    @SerializedName("sea_level")
    @Expose
    private Double seaLevel;
    @SerializedName("grnd_level")
    @Expose
    private Double grndLevel;

    /**
     * No args constructor for use in serialization
     */
    public Main() {
    }

    /**
     * @param seaLevel
     * @param humidity
     * @param pressure
     * @param grndLevel
     * @param tempMax
     * @param temp
     * @param tempMin
     */
    public Main(Double temp, Double pressure, Integer humidity, Double tempMin, Double tempMax, Double seaLevel, Double grndLevel) {
        this.temp = temp;
        this.pressure = pressure;
        this.humidity = humidity;
        this.tempMin = tempMin;
        this.tempMax = tempMax;
        this.seaLevel = seaLevel;
        this.grndLevel = grndLevel;
    }

    /**
     * @return The temp
     */
    public Double getTemp() {
        return temp;
    }

    /**
     * @param temp The temp
     */
    public void setTemp(Double temp) {
        this.temp = temp;
    }

    /**
     * @return The pressure
     */
    public Double getPressure() {
        return pressure;
    }

    /**
     * @param pressure The pressure
     */
    public void setPressure(Double pressure) {
        this.pressure = pressure;
    }

    /**
     * @return The humidity
     */
    public Integer getHumidity() {
        return humidity;
    }

    /**
     * @param humidity The humidity
     */
    public void setHumidity(Integer humidity) {
        this.humidity = humidity;
    }

    /**
     * @return The tempMin
     */
    public Double getTempMin() {
        return tempMin;
    }

    /**
     * @param tempMin The temp_min
     */
    public void setTempMin(Double tempMin) {
        this.tempMin = tempMin;
    }

    /**
     * @return The tempMax
     */
    public Double getTempMax() {
        return tempMax;
    }

    /**
     * @param tempMax The temp_max
     */
    public void setTempMax(Double tempMax) {
        this.tempMax = tempMax;
    }

    /**
     * @return The seaLevel
     */
    public Double getSeaLevel() {
        return seaLevel;
    }

    /**
     * @param seaLevel The sea_level
     */
    public void setSeaLevel(Double seaLevel) {
        this.seaLevel = seaLevel;
    }

    /**
     * @return The grndLevel
     */
    public Double getGrndLevel() {
        return grndLevel;
    }

    /**
     * @param grndLevel The grnd_level
     */
    public void setGrndLevel(Double grndLevel) {
        this.grndLevel = grndLevel;
    }

}


text:
class Aliexpress < ActiveRecord::Base
  has_many :crawlers
  validates :name, :email, :password, presence: true
  validates :name, :email, uniqueness: true

end


text:
window.loadedModules = window.loadedModules || [];
window.loadedModules.push("module-custom-bower-file");


text:
package uk.gov.nationalarchives.droid.results.handlers;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;

import javax.sql.DataSource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import uk.gov.nationalarchives.droid.core.interfaces.ResourceId;
import uk.gov.nationalarchives.droid.core.interfaces.filter.Filter;
import uk.gov.nationalarchives.droid.export.interfaces.ItemWriter;
import uk.gov.nationalarchives.droid.profile.ProfileResourceNode;
import uk.gov.nationalarchives.droid.profile.ProfileResourceNodeFilter;

/**
 * An implementation of ResultHandlerDao which writes results out to a Writer,
 * formatting them using an ItemWriter, instead of out to the profile database.
 * This can be used to output results to CSV on the console for example, or XML to a file.
 *

 * We inherit from the JDBCBatchResultHandlerDao class in order to get its
 * database operations for initialising the db and loading lists of formats.
 * Although these functions probably shouldn't belong in result handlers,
 * it's where they are now, and refactoring this turns out to be fairly
 * complex.  So we re-use all the database parts from the JDBCBatchResultHandler,
 * but override the methods involved in writing out to a Writer, and those
 * which can't work if the results aren't being saved to the database
 * (e.g. loading previous results or deleting previous results).
 */
public class WriterResultHandlerDao extends JDBCBatchResultHandlerDao {

    private static final Logger LOG = LoggerFactory.getLogger(WriterResultHandlerDao.class);

    private final List<ProfileResourceNode> items = new ArrayList<>(1);

    private ItemWriter itemWriter;
    private Writer writer;
    private long nodeId = 1L;
    private ProfileResourceNodeFilter filter = new ProfileResourceNodeFilter();

    /**
     * Empty bean constructor.  You still need to set the Itemwriter and DataSource,
     * and then call init() before this class is ready to use.  If you don't also set a Writer,
     * then output will go to the standard system out.
     */
    public WriterResultHandlerDao() {
    }

    /**
     * Parameterized constructor taking the ItemWriter to use to output results to standard out.
     * @param itemWriter The ItemWriter to write out results.
     * @param datasource The database connection to the profile for initialising new databases.
     */
    public WriterResultHandlerDao(ItemWriter itemWriter, DataSource datasource) {
        this(itemWriter, null, datasource);
    }

    /**
     * Parameterized constructor taking the ItemWriter to use to output results to a Writer.
     * @param itemWriter The ItemWriter which formats results and writes them to the writer.
     * @param writer The writer to which results are written.
     * @param datasource The database connection to the profile for initialising new databases.
     */
    public WriterResultHandlerDao(ItemWriter itemWriter, Writer writer, DataSource datasource) {
        setItemWriter(itemWriter);
        setWriter(writer);
        setDatasource(datasource);
    }

    @Override
    public synchronized void init() {
        try {
            super.init();
        } finally {
            if (writer == null) { // If no writer is set, default to console output.
                writer = new PrintWriter(System.out);
            }
            itemWriter.open(writer);
        }
    }

    @Override
    public synchronized void save(ProfileResourceNode node, ResourceId parentId) {
        node.setId(nodeId++);
        if (parentId != null) {
            node.setParentId(parentId.getId());
        }
        if (filter.passesFilter(node)) { // only write the result if it passes the filter.
            items.clear(); //TODO: we just output each result in a list of one - any value in batching them for output?
            items.add(node);
            itemWriter.write(items);
        }
    }

    @Override
    public synchronized void setFilter(Filter filter) {
        this.filter = new ProfileResourceNodeFilter(filter);
    }

    @Override
    public synchronized void commit() {
        try {
            writer.flush();
        } catch (IOException e) {
            LOG.error("Error flushing writer: " + e.getMessage(), e);
        }
    }

   /**
     * Note: This result handler cannot load any prior results, and always returns null.
     * {@inheritDoc}
     */
    @Override
    public ProfileResourceNode loadNode(final Long nodeIdToLoad) {
        return null;
    }

    /**
     * Note: This result handler cannot delete previous nodes, and this method does nothing.
     * {@inheritDoc}
     */
    @Override
    public void deleteNode(final Long nodeIdToDelete) {
    }

    /**
     * Sets the ItemWriter used to format results for output to a Writer.
     * @param itemWriter The ItemWriter used to format results for output to a Writer.
     */
    public synchronized void setItemWriter(ItemWriter itemWriter) {
        this.itemWriter = itemWriter;
    }

    /**
     * Sets the Writer to which results are written.
     * @param writer The Writer to which results are written.
     */
    public synchronized void setWriter(Writer writer) {
        this.writer = writer;
    }
}


text:
package org.perfcake.idea.editor.dialogs.tables;

import com.intellij.ui.table.JBTable;
import org.perfcake.idea.editor.actions.DeleteAction;
import org.perfcake.idea.editor.actions.EditAction;
import org.perfcake.idea.editor.actions.HeaderAddAction;
import org.perfcake.idea.model.Header;
import org.perfcake.idea.model.Message;

import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.AbstractTableModel;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by miron on 18. 11. 2014.
 */
public class HeaderEditor {
    List<Header> selectedHeaders = new ArrayList<Header>();
    private JPanel rootPanel;
    private JButton deleteButton;
    private JButton addButton;
    private JButton editButton;
    private JTable headerTable;
    private Message mockCopy;

    public HeaderEditor(final Message mockCopy) {
        this.mockCopy = mockCopy;

        HeaderAddAction addAction = new HeaderAddAction(mockCopy, headerTable);
        addButton.setAction(addAction);
        addButton.setText("Add");

        final EditAction editAction = new EditAction<Header>("Edit Header", selectedHeaders.isEmpty() ? null : selectedHeaders.get(0), headerTable);
        editButton.setAction(editAction);
        editButton.setText("Edit");

        final DeleteAction deleteAction = new DeleteAction<Header>("Delete Header", selectedHeaders, headerTable);
        deleteButton.setAction(deleteAction);
        deleteButton.setText("Delete");

        headerTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                selectedHeaders.clear();
                ListSelectionModel lsm = (ListSelectionModel) e.getSource();
                int minIndex = lsm.getMinSelectionIndex();
                int maxIndex = lsm.getMaxSelectionIndex();
                for(int i = minIndex; i <= maxIndex; i++){
                    if(lsm.isSelectedIndex(i)){
                        selectedHeaders.add(mockCopy.getHeaders().get(i));
                    }
                }
                if(selectedHeaders.isEmpty()){
                    deleteAction.setEnabled(false);
                }else{
                    deleteAction.setEnabled(true);
                    editAction.setDomElement(selectedHeaders.get(0));
                }
            }
        });

        headerTable.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    editButton.doClick();
                }
            }
        });
    }

    private void createUIComponents() {
        headerTable = new JBTable(new HeaderTableModel());
    }

    private class HeaderTableModel extends AbstractTableModel {
        private final String[] columnNames = {"Header name", "Header value"};

        @Override
        public int getRowCount() {
            return mockCopy.getHeaders().size();
        }

        @Override
        public int getColumnCount() {
            return 2;
        }

        @Override
        public String getColumnName(int column) {
            return columnNames[column];
        }

        @Override
        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return true;
        }

        @Override
        public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
            Header header = mockCopy.getHeaders().get(rowIndex);
            if(columnIndex == 0){
                header.getName().setStringValue((String) aValue);
            }
            if(columnIndex == 1){
                header.getValue().setStringValue((String) aValue);
            }
            fireTableCellUpdated(rowIndex, columnIndex);
        }

        @Override
        public Object getValueAt(int rowIndex, int columnIndex) {

                Header header = mockCopy.getHeaders().get(rowIndex);
                if (header.isValid()) {
                    if (columnIndex == 0) {
                        return header.getName();
                    }
                    if (columnIndex == 1) {
                        return header.getValue();
                    }
                }
                return null;
        }
    }
}


text:
package org.javamoney.moneta.internal.convert;

import java.io.IOException;
import java.io.InputStream;
import java.time.LocalDate;
import java.time.YearMonth;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.money.CurrencyUnit;
import javax.money.convert.ConversionQuery;
import javax.money.convert.ExchangeRate;
import javax.money.convert.ProviderContext;
import javax.money.convert.ProviderContextBuilder;
import javax.money.convert.RateType;
import javax.money.spi.Bootstrap;

import org.javamoney.moneta.internal.convert.IMFRateReadingHandler.RateIMFResult;
import org.javamoney.moneta.spi.LoaderService;

/**
 * Find by historic from IMF
 * @author otaviojava
 * @since 1.0.1
 */
public class IMFHistoricRateProvider extends IMFAbstractRateProvider {

    private static final Logger LOG = Logger.getLogger(IMFHistoricRateProvider.class.getName());

    private static final String DATA_ID = IMFHistoricRateProvider.class.getSimpleName();

	private static final ProviderContext CONTEXT = ProviderContextBuilder.of("IMF-HIST", RateType.HISTORIC)
	            .set("providerDescription", "Historic International Monetary Fond").set("days", 0).build();

	private final List<YearMonth> cachedHistoric = new ArrayList<>();
	public IMFHistoricRateProvider() {
		super(CONTEXT);
		 LoaderService loader = Bootstrap.getService(LoaderService.class);
	        loader.addLoaderListener(this, DATA_ID);
	        try {
	            loader.loadData(DATA_ID);
	        } catch (IOException e) {
	        	LOG.log(Level.WARNING, "Error loading initial data from IMF provider...", e);
	        }
	}

	@Override
	public ExchangeRate getExchangeRate(ConversionQuery conversionQuery) {
		LocalDate[] times = getQueryDates(conversionQuery);
		if(Objects.isNull(times)) {
			return super.getExchangeRate(conversionQuery);
		}

		for (YearMonth yearMonth : Stream.of(times).map(YearMonth::from)
				.collect(Collectors.toSet())) {

			if(!cachedHistoric.contains(yearMonth)){
				Map<IMFHistoricalType, InputStream> resources = IMFRemoteSearch.INSTANCE.getResources(yearMonth);
				loadFromRemote(resources);
				cachedHistoric.add(yearMonth);
			}
		}
		return super.getExchangeRate(conversionQuery);
	}

	private void loadFromRemote(Map<IMFHistoricalType, InputStream> resources) {
		try {
			for(IMFHistoricalType type: resources.keySet()) {
				RateIMFResult result = handler.read(resources.get(type));
				combine(result.getSdrToCurrency(), this.sdrToCurrency);
				combine(result.getCurrencyToSdr(), this.currencyToSdr);
			}
	    } catch (Exception e) {
	    	LOG.log(Level.SEVERE, "Error", e);
	    }
	}

	private Map<CurrencyUnit, List<ExchangeRate>> combine(Map<CurrencyUnit, List<ExchangeRate>> source, Map<CurrencyUnit, List<ExchangeRate>> destination) {
		for(CurrencyUnit currency: source.keySet()) {
			destination.putIfAbsent(currency, new ArrayList<>());
			List<ExchangeRate> rates = source.get(currency);
			destination.merge(currency, rates, IMFHistoricRateProvider::merge);
		}
		return destination;
	}
	private static List<ExchangeRate> merge(List<ExchangeRate> ratesA, List<ExchangeRate> ratesB) {
		ratesA.addAll(ratesB);
		ratesA.sort(COMPARATOR_EXCHANGE_BY_LOCAL_DATE.reversed());
		return ratesA;
	}
}


text:
import {handleActions} from 'redux-actions';
import update from 'immutability-helper';
import * as constants from '../../../redux/constants';
import '../../../redux/update';

let initialState = {
  attendanceUploadSetting: {
    data: [],
    isLoading: false,
    isError: false,
    isSuccess: false,
    message: ""
  },
  addAttendanceUploadSetting: {
    isLoading: false,
    isError: false,
    isSuccess: false,
    message: ""
  },
  deleteAttendanceUploadSetting: {
    isLoading: false,
    isError: false,
    isSuccess: false,
    message: ""
  },
  resetPasswordStatus: {
    isLoading: false,
    isError: false,
    isSuccess: false,
    message: "",
    data: {}
  }
};

const requestAttendanceUploadSetting = (state, action) =>
  update(state, {
    attendanceUploadSetting: {
      isLoading: { $set: true },
      isError: { $set: false },
      isSuccess: { $set: false },
      message: { $set: "" }
    }
  });
const successGetAttendanceUploadSetting = (state, action) =>
  update(state, {
    attendanceUploadSetting: {
      data: { $set: action.payload },
      isLoading: { $set: false },
      isError: { $set: false },
      isSuccess: { $set: true },
      message: { $set: "" }
    }
  });
const errorAttendanceUploadSetting = (state, action) =>
  update(state, {
    attendanceUploadSetting: {
      isLoading: { $set: false },
      isError: { $set: true },
      isSuccess: { $set: false },
      message: { $set: action.payload }
    }
  });

// const requestAddAttendanceUploadSetting = (state, action) => update(state, {
//   addAttendanceUploadSetting: {
//     isLoading: {$set: true},
//     isError:   {$set: false},
//     isSuccess: {$set: false},
//     message:   {$set: ''}
//   }
// });
const successAttendanceUploadSettingActions = (state, action) =>
  update(state, {
    addAttendanceUploadSetting: {
      isLoading: { $set: false },
      isError: { $set: false },
      isSuccess: { $set: true },
      message: { $set: "" }
    }
  });
// const errorAddAttendanceUploadSetting = (state, action) => update(state, {
//   addAttendanceUploadSetting: {
//     isLoading: {$set: false},
//     isError:   {$set: true},
//     isSuccess: {$set: false},
//     message:   {$set: 'Error !'}
//   }
// });

// const requestDeleteAttendanceUploadSetting = (state, action) => update(state, {
//   deleteAttendanceUploadSetting: {
//     isLoading: {$set: true},
//     isError:   {$set: false},
//     isSuccess: {$set: false},
//     message:   {$set: ''}
//   }
// });
// const successDeleteAttendanceUploadSetting = (state, action) => update(state, {
//   deleteAttendanceUploadSetting: {
//     isLoading: {$set: false},
//     isError:   {$set: false},
//     isSuccess: {$set: true},
//     message:   {$set: ''}
//   }
// });
// const errorDeleteAttendanceUploadSetting = (state, action) => update(state, {
//   deleteAttendanceUploadSetting: {
//     isLoading: {$set: false},
//     isError:   {$set: true},
//     isSuccess: {$set: false},
//     message:   {$set: 'Error !'}
//   }
// });

const successResetPasswordStatus = (state, action) =>
  update(state, {
    resetPasswordStatus: {
      isLoading: { $set: false },
      isError: { $set: false },
      isSuccess: { $set: true },
      message: { $set: "Error !" },
      data: { $set: action.payload.data }
    }
  });

  const successClearResetPasswordData = (state, action) =>
  update(state, {
    resetPasswordStatus: {
      isLoading: { $set: false },
      isError: { $set: false },
      isSuccess: { $set: true },
      message: { $set: "Error !" },
      data: { $set: {} }
    }
  });

export default handleActions(
  {
    [constants.REQUEST_GET_ATTANDANCE_UPLOAD_SETTING]: requestAttendanceUploadSetting,
    [constants.SUCCESS_GET_ATTANDANCE_UPLOAD_SETTING]: successGetAttendanceUploadSetting,
    [constants.ERROR_GET_ATTANDANCE_UPLOAD_SETTING]: errorAttendanceUploadSetting,

    [constants.REQUEST_ADD_ATTANDANCE_UPLOAD_SETTING]: requestAttendanceUploadSetting,
    [constants.SUCCESS_ADD_ATTANDANCE_UPLOAD_SETTING]: successAttendanceUploadSettingActions,
    [constants.ERROR_ADD_ATTANDANCE_UPLOAD_SETTING]: errorAttendanceUploadSetting,

    [constants.REQUEST_DELETE_ATTANDANCE_UPLOAD_SETTING]: requestAttendanceUploadSetting,
    [constants.SUCCESS_DELETE_ATTANDANCE_UPLOAD_SETTING]: successAttendanceUploadSettingActions,
    [constants.ERROR_DELETE_ATTANDANCE_UPLOAD_SETTING]: errorAttendanceUploadSetting,
    [constants.SUCCESS_RESET_PASSWORD_STATUS]: successResetPasswordStatus,
    [constants.SUCCESS_CLEAR_RESET_PASSWORD_DATA]:successClearResetPasswordData,
  },
  initialState
);


text:
MissileTower::MissileTower(float x, float y) : Tower(Tower_Type::MISSILE_TYPE, x, y, 1, 1, 3.2f, 8.0f, 65)
{
	m_explosionType = Explosion_Type::MINI_DAMAGE;
	m_missileState = Missile_State::MISSILES_WAITING;
	m_fProjectileSpeed = 5.00f;
	m_fMissileWaitTime = 0.50f;
	m_fTimeSinceLastShot = 0;
	m_fCooldownTime = 3.40f;
	m_fProjectileWidth = 0.576f;
	m_fProjectileHeight = 0.08f;
	m_iProjectileDamage = 1600;
	m_iMissilesFired = 0;
}

Tower_Type MissileTower::getTowerType()
{
	return Tower_Type::MISSILE_TYPE;
}

void MissileTower::updateReady(float deltaTime, std::vector<std::unique_ptr<Creep>> &creeps)
{
	m_fTimeSinceLastShot += deltaTime;

	checkCreepInRadius(creeps);
}

void MissileTower::fireAtCreep(Creep *creep)
{
	if (m_missileState == Missile_State::MISSILES_WAITING)
	{
		if (m_fTimeSinceLastShot > m_fCooldownTime)
		{
			m_missileState = Missile_State::MISSILES_FIRING;
			m_fTimeSinceLastShot = 0;
		}
	}
	else if (m_fTimeSinceLastShot > m_fMissileWaitTime)
	{
        GameListener::getInstance()->playSound(SOUND_MISSILE_LAUNCH);

        float radians = DEGREES_TO_RADIANS(m_fAngle);
		float cos = cosf(radians);
		float sin = sinf(radians);

		World::getInstance()->getMissiles().push_back(std::unique_ptr<Missile>(new Missile(m_position->getX() + (cos * 0.30f), m_position->getY() + (sin * 0.30f), m_fProjectileWidth, m_fProjectileHeight, m_fProjectileSpeed, m_fAngle, m_iProjectileDamage, m_explosionType, creep)));
		m_iMissilesFired++;
		if (m_iMissilesFired > getStage())
		{
			m_missileState = Missile_State::MISSILES_WAITING;
			m_iMissilesFired = 0;
		}

		m_fTimeSinceLastShot = 0;
	}
}

void MissileTower::performUpgrade()
{
	if (getStage() == 2)
	{
		m_explosionType = Explosion_Type::BIG_DAMAGE;
	}

	m_iUpgradeCost += 70;
	m_fTimeSinceLastShot = 0;
	m_fCooldownTime -= 0.20f;
	m_fProjectileWidth += 0.0835f;
	m_fProjectileHeight += 0.025f;
	m_iProjectileDamage += 400;

	m_attackRadius->m_fRadius += 0.40f;
}

void MissileTower::checkCreepInRadius(std::vector<std::unique_ptr<Creep>> &creeps)
{
	for (std::vector<std::unique_ptr<Creep>>::iterator itr = creeps.begin(); itr != creeps.end(); itr++)
	{
		if ((*itr)->canMissilesTarget() && OverlapTester::isPointInCircle((*itr)->getPosition(), *m_attackRadius))
		{
			Vector2D creepPosition = (*itr)->getPosition().cpy();
			m_fAngle = creepPosition.sub(m_position->getX(), m_position->getY()).angle();

			fireAtCreep(itr->get());

			return;
		}
	}
}


text:
namespace google {
	namespace protobuf {
		class Message;
	}
}

int	protobuf_msg_to_xml_file(const google::protobuf::Message & msg, const std::string & xmlfile);
int	protobuf_msg_from_xml_file(google::protobuf::Message & msg, const std::string & xmlfile, std::string & error);
int	protobuf_msg_to_xml_string(const google::protobuf::Message & msg, std::string & sxml);
int	protobuf_msg_from_xml_string(google::protobuf::Message & msg, const std::string & sxml, std::string & error);