text:
package com.streamsets.lib.security.http;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableSet;
import com.streamsets.datacollector.util.Configuration;
import com.streamsets.pipeline.api.impl.Utils;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jetty.security.ServerAuthException;
import org.eclipse.jetty.server.Authentication;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Collections;
import java.util.Set;

public class SSOUserAuthenticator extends AbstractSSOAuthenticator {
  private static final Logger LOG = LoggerFactory.getLogger(SSOUserAuthenticator.class);

  private static final Set<String> TOKEN_PARAM_SET =
      ImmutableSet.of(SSOConstants.USER_AUTH_TOKEN_PARAM, SSOConstants.REPEATED_REDIRECT_PARAM);

  public static final String HTTP_META_REDIRECT_TO_SSO = "http.meta.redirect.to.sso";
  private static final String BASE_HTTP_URL_ATTR = "%s.base.http.url";

  private Configuration conf;
  private boolean doMetaRedirectToSso;
  private String dpmBaseUrl;
  private final boolean isDataCollector;
  private String engineBaseHttpUrl;

  public SSOUserAuthenticator(
      SSOService ssoService,
      @NotNull Configuration conf
  ) {
    this(ssoService, conf, null);
  }

  public SSOUserAuthenticator(
      SSOService ssoService,
      @NotNull Configuration conf,
      String productName
  ) {
    super(ssoService);
    this.conf = conf;

    this.dpmBaseUrl = conf.get(RemoteSSOService.DPM_BASE_URL_CONFIG, null);
    this.isDataCollector = !conf.hasName(RemoteSSOService.DPM_APP_SECURITY_URL_CONFIG);
    this.doMetaRedirectToSso = conf.get(HTTP_META_REDIRECT_TO_SSO, false);

    if (StringUtils.isNotEmpty(this.dpmBaseUrl) && this.dpmBaseUrl.endsWith("/")) {
      this.dpmBaseUrl = this.dpmBaseUrl.substring(0, this.dpmBaseUrl.length() - 1);
    }

    if (isDataCollector) {
      this.engineBaseHttpUrl = conf.get(String.format(BASE_HTTP_URL_ATTR, productName), null);
    }
  }

  @Override
  protected Logger getLog() {
    return LOG;
  }

  StringBuffer getRequestUrl(HttpServletRequest request, Set<String> queryStringParamsToRemove) {
    StringBuffer requestUrl;

    if (this.dpmBaseUrl != null && !isDataCollector) {
      requestUrl = new StringBuffer(this.dpmBaseUrl);
      requestUrl.append(request.getRequestURI());
    } else if (this.engineBaseHttpUrl != null && this.isDataCollector) {
      requestUrl = new StringBuffer(this.engineBaseHttpUrl);
    } else {
      requestUrl = new StringBuffer(request.getRequestURL());
    }

    String qs = request.getQueryString();
    if (qs != null) {
      String qsSeparator = "?";
      for (String paramArg : Splitter.on("&").split(qs)) {
        String[] paramArgArr = paramArg.split("=", 2);
        if (!queryStringParamsToRemove.contains(paramArgArr[0])) {
          requestUrl.append(qsSeparator).append(paramArg);
          qsSeparator = "&";
        }
      }
    }
    return requestUrl;
  }

  String getRequestUrl(HttpServletRequest request) {
    return getRequestUrl(request, Collections.emptySet()).toString();
  }

  String getRequestUrlWithoutToken(HttpServletRequest request) {
    return getRequestUrl(request, TOKEN_PARAM_SET).toString();
  }

  /*
   * Creates Login url with request URL as parameter for a callback redirection on a successful login.
   */
  String getLoginUrl(
      HttpServletRequest request,
      boolean repeatedRedirect,
      HttpServletRequest httpReq,
      HttpServletResponse httpRes
  ) {
    String requestUrl = getRequestUrl(request, TOKEN_PARAM_SET).toString();
    return getSsoService().createRedirectToLoginUrl(requestUrl, repeatedRedirect, httpReq, httpRes);
  }

  /*
   * Removes the token from request URL, redirects to the modified URL, returns the token as a header
   */
  Authentication redirectToSelf(HttpServletRequest httpReq, HttpServletResponse httpRes) throws ServerAuthException {
    String authToken = httpReq.getParameter(SSOConstants.USER_AUTH_TOKEN_PARAM);
    String urlWithoutToken = getRequestUrlWithoutToken(httpReq);
    httpRes.setHeader(SSOConstants.X_USER_AUTH_TOKEN, authToken);
    try {
      LOG.debug("Redirecting to self without token '{}'", urlWithoutToken);
      httpRes.sendRedirect(urlWithoutToken);
      return Authentication.SEND_CONTINUE;
    } catch (IOException ex) {
      throw new ServerAuthException(Utils.format("Could not redirect to '{}': {}", urlWithoutToken, ex.toString(), ex));
    }
  }

  @VisibleForTesting
  static final String HTML_META_REDIRECT =
      "<meta http-equiv=\"refresh\" content=\"0; url='%s'\"/>";

  Authentication redirectToLogin(HttpServletRequest httpReq, HttpServletResponse httpRes) throws ServerAuthException {
    boolean repeatedRedirect = httpReq.getParameter(SSOConstants.REPEATED_REDIRECT_PARAM) != null;
    String urlToLogin = getLoginUrl(httpReq, repeatedRedirect, httpReq, httpRes);
    try {
      LOG.debug("Redirecting to login '{}'", urlToLogin);
      if (doMetaRedirectToSso) {
        httpRes.setContentType("text/html");
        httpRes.setStatus(HttpServletResponse.SC_OK);
        httpRes.getWriter().println(String.format(HTML_META_REDIRECT, urlToLogin));
      } else {
        httpRes.sendRedirect(urlToLogin);
      }
      return Authentication.SEND_CONTINUE;
    } catch (IOException ex) {
      throw new ServerAuthException(Utils.format("Could not redirect to '{}': {}", urlToLogin, ex.toString(), ex));
    }
  }

  Authentication redirectToLogout(HttpServletResponse httpRes) throws ServerAuthException {
    String urlToLogout = getSsoService().getLogoutUrl();
    try {
      LOG.debug("Redirecting to logout '{}'", urlToLogout);
      httpRes.sendRedirect(urlToLogout);
      return Authentication.SEND_SUCCESS;
    } catch (IOException ex) {
      throw new ServerAuthException(Utils.format("Could not redirect to '{}': {}", urlToLogout, ex.toString(), ex));
    }
  }

  /*
   * Terminates the request with an HTTP Unauthorized response or redirects to login for page requests
   */
  @Override
  protected Authentication returnUnauthorized(
      HttpServletRequest httpReq, HttpServletResponse httpRes, String principalId, String logMessageTemplate
  ) throws ServerAuthException {
    Authentication ret;
    httpRes.addCookie(createAuthCookie(httpReq, "", 0));
    if (httpReq.getHeader(SSOConstants.X_REST_CALL) != null) {
      ret = super.returnUnauthorized(httpReq, httpRes, null, logMessageTemplate);
    } else {
      redirectToLogin(httpReq, httpRes);
      ret = Authentication.SEND_FAILURE;
    }
    return ret;
  }

  Cookie createAuthCookie(HttpServletRequest httpReq, String authToken, long expiresMillis) {
    Cookie authCookie = new Cookie(getAuthCookieName(httpReq), authToken);
    authCookie.setPath("/");
    // if positive it is a persistent session, else a transient one and we don't have to set the cookie age
    if (expiresMillis > 0) {
      int secondsToLive = (int) ((expiresMillis - System.currentTimeMillis()) / 1000);
      authCookie.setMaxAge(secondsToLive);
    } else if (expiresMillis == 0) {
      // to delete the cookie
      authCookie.setMaxAge(0);
    }

    if (isDataCollector) {
      // When an SDC is accessing SCH, set the cookie based on the SDC's scheme
      authCookie.setSecure(httpReq.isSecure());
    } else {
      // When a browser accesses SCH, set the cookie based on the SCH endpoint
      authCookie.setSecure(dpmBaseUrl.startsWith("https"));
    }

    return authCookie;
  }

  void setAuthCookieIfNecessary(HttpServletRequest req, HttpServletResponse res, String authToken, long expiresMillis) {
    if (!authToken.equals(getAuthTokenFromCookie(req))) {
      res.addCookie(createAuthCookie(req, authToken, expiresMillis));
    }
  }

  boolean isLogoutRequest( HttpServletRequest httpReq) {
    String logoutPath = httpReq.getContextPath() + "/logout";
    return httpReq.getMethod().equals("GET") && httpReq.getRequestURI().equals(logoutPath);
  }

  private boolean isCORSOptionsRequest(HttpServletRequest httpReq) {
    return "OPTIONS".equals(httpReq.getMethod());
  }

  String getAuthCookieName(HttpServletRequest httpReq) {
    return SSOConstants.AUTHENTICATION_COOKIE_PREFIX + httpReq.getServerPort();
  }

  Cookie getAuthCookie(HttpServletRequest httpReq) {
    Cookie[] cookies = httpReq.getCookies();
    if (cookies != null) {
      for (Cookie cookie : cookies) {
        if (cookie.getName().equals(getAuthCookieName(httpReq))) {
          return cookie;
        }
      }
    }
    return null;
  }

  String getAuthTokenFromCookie(HttpServletRequest httpReq) {
    Cookie cookie = getAuthCookie(httpReq);
    return (cookie == null) ? null : cookie.getValue();
  }

  boolean isAuthTokenInQueryString(HttpServletRequest httpReq) {
    return httpReq.getParameter(SSOConstants.USER_AUTH_TOKEN_PARAM) != null;
  }

  String getAuthTokenFromRequest(HttpServletRequest httpReq) {
    String authToken = httpReq.getParameter(SSOConstants.USER_AUTH_TOKEN_PARAM);
    if (authToken == null) {
      authToken = httpReq.getHeader(SSOConstants.X_USER_AUTH_TOKEN);
      if (authToken == null) {
        authToken = getAuthTokenFromCookie(httpReq);
      }
    }
    return authToken;
  }

  @Override
  public Authentication validateRequest(ServletRequest request, ServletResponse response, boolean mandatory)
      throws ServerAuthException {
    HttpServletRequest httpReq = (HttpServletRequest) request;
    HttpServletResponse httpRes = (HttpServletResponse) response;
    String authToken = getAuthTokenFromRequest(httpReq);

    Authentication ret = null;

    if (LOG.isTraceEnabled()) {
      LOG.trace("Request: {}", getRequestInfoForLogging(httpReq, SSOUtils.tokenForLog(authToken)));
    }

    if (isCORSOptionsRequest(httpReq)) {
      httpRes.setStatus(HttpServletResponse.SC_OK);
      httpRes.setHeader("Access-Control-Allow-Origin", conf.get(CORSConstants.HTTP_ACCESS_CONTROL_ALLOW_ORIGIN,
          CORSConstants.HTTP_ACCESS_CONTROL_ALLOW_ORIGIN_DEFAULT));
      httpRes.setHeader("Access-Control-Allow-Headers", conf.get(CORSConstants.HTTP_ACCESS_CONTROL_ALLOW_HEADERS,
          CORSConstants.HTTP_ACCESS_CONTROL_ALLOW_HEADERS_DEFAULT));
      httpRes.setHeader("Access-Control-Allow-Methods", conf.get(CORSConstants.HTTP_ACCESS_CONTROL_ALLOW_METHODS,
          CORSConstants.HTTP_ACCESS_CONTROL_ALLOW_METHODS_DEFAULT));
      return Authentication.SEND_SUCCESS;
    }

    if (!mandatory) {
      ret = Authentication.NOT_CHECKED;
    } else {
      if (authToken != null) {
        try {
          SSOPrincipal principal = getSsoService().validateUserToken(authToken);
          if (principal != null) {
            SSOAuthenticationUser user = new SSOAuthenticationUser(principal);
            if (isLogoutRequest(httpReq)) {
              if (LOG.isTraceEnabled()) {
                LOG.trace("Principal '{}' Logout", principal.getPrincipalId());
              }
              getSsoService().invalidateUserToken(authToken);
              ret = redirectToLogout(httpRes);
            } else {
              setAuthCookieIfNecessary(httpReq, httpRes, authToken, user.getSSOUserPrincipal().getExpires());
              if (isAuthTokenInQueryString(httpReq)) {
                if (LOG.isTraceEnabled()) {
                  LOG.trace(
                      "Redirection to self, principal '{}' request: {}",
                      principal.getPrincipalId(),
                      getRequestInfoForLogging(httpReq, SSOUtils.tokenForLog(authToken))
                  );
                }
                ret = redirectToSelf(httpReq, httpRes);
              } else {
                if (LOG.isDebugEnabled()) {
                  LOG.debug(
                      "Principal '{}' request: {}",
                      principal.getPrincipalId(),
                      getRequestInfoForLogging(httpReq, SSOUtils.tokenForLog(authToken))
                  );
                }
                ret = user;
              }
            }
          }
        } catch (ForbiddenException fex) {
          ret = returnUnauthorized(httpReq, httpRes, fex.getErrorInfo(), null, "Request: {}");
        }
      }
    }
    if (ret == null) {
      ret = returnUnauthorized(httpReq, httpRes, SSOUtils.tokenForLog(authToken), "Could not authenticate: {}");
    }
    return ret;
  }

}


text:
using Andi.Controls;
using Andi.Controls.ImageBox;
using Andi.Controls.TabControl;
using Andi.Libs.HexBox;

namespace Andi.Toolkit.gen0
{
    partial class vEvolutions
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.toolStrip1 = new System.Windows.Forms.ToolStrip();
            this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
            this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
            this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel();
            this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
            this.toolStripComboBox1 = new System.Windows.Forms.ToolStripComboBox();
            this.toolStripLabel2 = new System.Windows.Forms.ToolStripLabel();
            this.toolStripLabel3 = new System.Windows.Forms.ToolStripLabel();
            this.splitContainer1 = new System.Windows.Forms.SplitContainer();
            this.andiListBox1 = new AndiListBox();
            this.andiCustomTabControl1 = new AndiCustomTabControl();
            this.tabPage1 = new System.Windows.Forms.TabPage();
            this.andiGroupBox2 = new AndiGroupBox();
            this.andiImageBox1 = new AndiImageBox();
            this.grid1 = new SourceGrid.Grid();
            this.andiImageComboBox3 = new AndiImageComboBox();
            this.label4 = new System.Windows.Forms.Label();
            this.label1 = new System.Windows.Forms.Label();
            this.andiImageComboBox2 = new AndiImageComboBox();
            this.label2 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.andiImageComboBox1 = new AndiImageComboBox();
            this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
            this.andiGroupBox1 = new AndiGroupBox();
            this.pkm_1 = new AndiImageBox();
            this.andiImageComboBox4 = new AndiImageComboBox();
            this.label5 = new System.Windows.Forms.Label();
            this.tabPage2 = new System.Windows.Forms.TabPage();
            this.hexBox1 = new HexBox();
            this.toolStrip1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
            this.splitContainer1.Panel1.SuspendLayout();
            this.splitContainer1.Panel2.SuspendLayout();
            this.splitContainer1.SuspendLayout();
            this.andiCustomTabControl1.SuspendLayout();
            this.tabPage1.SuspendLayout();
            this.andiGroupBox2.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
            this.andiGroupBox1.SuspendLayout();
            this.tabPage2.SuspendLayout();
            this.SuspendLayout();
            //
            // toolStrip1
            //
            this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.toolStripButton1,
            this.toolStripButton2,
            this.toolStripLabel1,
            this.toolStripSeparator1,
            this.toolStripComboBox1,
            this.toolStripLabel2,
            this.toolStripLabel3});
            this.toolStrip1.Location = new System.Drawing.Point(0, 0);
            this.toolStrip1.Name = "toolStrip1";
            this.toolStrip1.Size = new System.Drawing.Size(635, 25);
            this.toolStrip1.TabIndex = 0;
            this.toolStrip1.Text = "toolStrip1";
            //
            // toolStripButton1
            //
            this.toolStripButton1.Image = global::Andi.Toolkit.Properties.Resources.folder_open;
            this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton1.Name = "toolStripButton1";
            this.toolStripButton1.Size = new System.Drawing.Size(56, 22);
            this.toolStripButton1.Text = "Open";
            this.toolStripButton1.Click += new System.EventHandler(this.OpenFile_Click);
            //
            // toolStripButton2
            //
            this.toolStripButton2.Image = global::Andi.Toolkit.Properties.Resources.disk;
            this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton2.Name = "toolStripButton2";
            this.toolStripButton2.Size = new System.Drawing.Size(51, 22);
            this.toolStripButton2.Text = "Save";
            this.toolStripButton2.Click += new System.EventHandler(this.SaveFile_Click);
            //
            // toolStripLabel1
            //
            this.toolStripLabel1.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
            this.toolStripLabel1.Name = "toolStripLabel1";
            this.toolStripLabel1.Size = new System.Drawing.Size(13, 22);
            this.toolStripLabel1.Text = "0";
            //
            // toolStripSeparator1
            //
            this.toolStripSeparator1.Name = "toolStripSeparator1";
            this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25);
            //
            // toolStripComboBox1
            //
            this.toolStripComboBox1.Items.AddRange(new object[] {
            "DP",
            "PtHGSS",
            "BW",
            "BW2"});
            this.toolStripComboBox1.Name = "toolStripComboBox1";
            this.toolStripComboBox1.Size = new System.Drawing.Size(121, 25);
            //
            // toolStripLabel2
            //
            this.toolStripLabel2.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
            this.toolStripLabel2.ForeColor = System.Drawing.Color.Maroon;
            this.toolStripLabel2.Name = "toolStripLabel2";
            this.toolStripLabel2.Size = new System.Drawing.Size(13, 22);
            this.toolStripLabel2.Text = "0";
            //
            // toolStripLabel3
            //
            this.toolStripLabel3.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
            this.toolStripLabel3.ForeColor = System.Drawing.SystemColors.ScrollBar;
            this.toolStripLabel3.Name = "toolStripLabel3";
            this.toolStripLabel3.Size = new System.Drawing.Size(13, 22);
            this.toolStripLabel3.Text = "0";
            //
            // splitContainer1
            //
            this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
            this.splitContainer1.Location = new System.Drawing.Point(0, 25);
            this.splitContainer1.Name = "splitContainer1";
            //
            // splitContainer1.Panel1
            //
            this.splitContainer1.Panel1.Controls.Add(this.andiListBox1);
            //
            // splitContainer1.Panel2
            //
            this.splitContainer1.Panel2.Controls.Add(this.andiCustomTabControl1);
            this.splitContainer1.Size = new System.Drawing.Size(635, 427);
            this.splitContainer1.SplitterDistance = 136;
            this.splitContainer1.TabIndex = 3;
            //
            // andiListBox1
            //
            this.andiListBox1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.andiListBox1.FormattingEnabled = true;
            this.andiListBox1.ItemHeight = 17;
            this.andiListBox1.Location = new System.Drawing.Point(0, 0);
            this.andiListBox1.Name = "andiListBox1";
            this.andiListBox1.Size = new System.Drawing.Size(136, 427);
            this.andiListBox1.TabIndex = 0;
            this.andiListBox1.SelectedIndexChanged += new System.EventHandler(this.andiListBox1_SelectedIndexChanged);
            //
            // andiCustomTabControl1
            //
            this.andiCustomTabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
            | System.Windows.Forms.AnchorStyles.Left)
            | System.Windows.Forms.AnchorStyles.Right)));
            this.andiCustomTabControl1.Controls.Add(this.tabPage1);
            this.andiCustomTabControl1.Controls.Add(this.tabPage2);
            this.andiCustomTabControl1.DisplayStyle = TabStyle.VisualStudio;
            //
            //
            //
            this.andiCustomTabControl1.DisplayStyleProvider.BorderColor = System.Drawing.SystemColors.ControlDark;
            this.andiCustomTabControl1.DisplayStyleProvider.BorderColorHot = System.Drawing.SystemColors.ControlDark;
            this.andiCustomTabControl1.DisplayStyleProvider.BorderColorSelected = System.Drawing.Color.FromArgb(((int)(((byte)(127)))), ((int)(((byte)(157)))), ((int)(((byte)(185)))));
            this.andiCustomTabControl1.DisplayStyleProvider.CloserColor = System.Drawing.Color.DarkGray;
            this.andiCustomTabControl1.DisplayStyleProvider.FocusTrack = false;
            this.andiCustomTabControl1.DisplayStyleProvider.HotTrack = true;
            this.andiCustomTabControl1.DisplayStyleProvider.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.andiCustomTabControl1.DisplayStyleProvider.Opacity = 1F;
            this.andiCustomTabControl1.DisplayStyleProvider.Overlap = 7;
            this.andiCustomTabControl1.DisplayStyleProvider.Padding = new System.Drawing.Point(14, 1);
            this.andiCustomTabControl1.DisplayStyleProvider.ShowTabCloser = false;
            this.andiCustomTabControl1.DisplayStyleProvider.TextColor = System.Drawing.SystemColors.ControlText;
            this.andiCustomTabControl1.DisplayStyleProvider.TextColorDisabled = System.Drawing.SystemColors.ControlDark;
            this.andiCustomTabControl1.DisplayStyleProvider.TextColorSelected = System.Drawing.SystemColors.ControlText;
            this.andiCustomTabControl1.HotTrack = true;
            this.andiCustomTabControl1.Location = new System.Drawing.Point(2, 0);
            this.andiCustomTabControl1.Name = "andiCustomTabControl1";
            this.andiCustomTabControl1.SelectedIndex = 0;
            this.andiCustomTabControl1.Size = new System.Drawing.Size(489, 427);
            this.andiCustomTabControl1.TabIndex = 1;
            //
            // tabPage1
            //
            this.tabPage1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(239)))), ((int)(((byte)(239)))), ((int)(((byte)(242)))));
            this.tabPage1.Controls.Add(this.andiGroupBox2);
            this.tabPage1.Controls.Add(this.andiGroupBox1);
            this.tabPage1.Location = new System.Drawing.Point(4, 21);
            this.tabPage1.Name = "tabPage1";
            this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
            this.tabPage1.Size = new System.Drawing.Size(481, 402);
            this.tabPage1.TabIndex = 0;
            this.tabPage1.Text = "List";
            //
            // andiGroupBox2
            //
            this.andiGroupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
            | System.Windows.Forms.AnchorStyles.Left)
            | System.Windows.Forms.AnchorStyles.Right)));
            this.andiGroupBox2.Controls.Add(this.andiImageBox1);
            this.andiGroupBox2.Controls.Add(this.grid1);
            this.andiGroupBox2.Controls.Add(this.andiImageComboBox3);
            this.andiGroupBox2.Controls.Add(this.label4);
            this.andiGroupBox2.Controls.Add(this.label1);
            this.andiGroupBox2.Controls.Add(this.andiImageComboBox2);
            this.andiGroupBox2.Controls.Add(this.label2);
            this.andiGroupBox2.Controls.Add(this.label3);
            this.andiGroupBox2.Controls.Add(this.andiImageComboBox1);
            this.andiGroupBox2.Controls.Add(this.numericUpDown1);
            this.andiGroupBox2.Location = new System.Drawing.Point(4, 49);
            this.andiGroupBox2.Name = "andiGroupBox2";
            this.andiGroupBox2.Size = new System.Drawing.Size(473, 354);
            this.andiGroupBox2.TabIndex = 37;
            this.andiGroupBox2.TabStop = false;
            this.andiGroupBox2.Text = "Evolution List / Table";
            //
            // andiImageBox1
            //
            this.andiImageBox1.AutoScroll = false;
            this.andiImageBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.andiImageBox1.IndexParent = 0;
            this.andiImageBox1.Location = new System.Drawing.Point(241, 85);
            this.andiImageBox1.Name = "andiImageBox1";
            this.andiImageBox1.Size = new System.Drawing.Size(32, 32);
            this.andiImageBox1.TabIndex = 34;
            //
            // grid1
            //
            this.grid1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
            | System.Windows.Forms.AnchorStyles.Left)
            | System.Windows.Forms.AnchorStyles.Right)));
            this.grid1.EnableSort = true;
            this.grid1.Location = new System.Drawing.Point(6, 123);
            this.grid1.Name = "grid1";
            this.grid1.OptimizeMode = SourceGrid.CellOptimizeMode.ForRows;
            this.grid1.SelectionMode = SourceGrid.GridSelectionMode.Cell;
            this.grid1.Size = new System.Drawing.Size(461, 230);
            this.grid1.TabIndex = 26;
            this.grid1.TabStop = true;
            this.grid1.ToolTipText = "";
            //
            // andiImageComboBox3
            //
            this.andiImageComboBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
            | System.Windows.Forms.AnchorStyles.Right)));
            this.andiImageComboBox3.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
            this.andiImageComboBox3.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
            this.andiImageComboBox3.DropDownWidth = 500;
            this.andiImageComboBox3.FormattingEnabled = true;
            this.andiImageComboBox3.ItemHeight = 17;
            this.andiImageComboBox3.Location = new System.Drawing.Point(93, 19);
            this.andiImageComboBox3.Name = "andiImageComboBox3";
            this.andiImageComboBox3.Size = new System.Drawing.Size(374, 23);
            this.andiImageComboBox3.TabIndex = 25;
            this.andiImageComboBox3.SelectedIndexChanged += new System.EventHandler(this.andiImageComboBox3_SelectedIndexChanged);
            this.andiImageComboBox3.TextUpdate += new System.EventHandler(this.textupdate1);
            //
            // label4
            //
            this.label4.AutoSize = true;
            this.label4.Location = new System.Drawing.Point(20, 97);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(67, 13);
            this.label4.TabIndex = 33;
            this.label4.Text = "Evolve Into :";
            //
            // label1
            //
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(38, 22);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(49, 13);
            this.label1.TabIndex = 27;
            this.label1.Text = "Method :";
            //
            // andiImageComboBox2
            //
            this.andiImageComboBox2.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
            this.andiImageComboBox2.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
            this.andiImageComboBox2.FormattingEnabled = true;
            this.andiImageComboBox2.ItemHeight = 17;
            this.andiImageComboBox2.Location = new System.Drawing.Point(93, 94);
            this.andiImageComboBox2.Name = "andiImageComboBox2";
            this.andiImageComboBox2.Size = new System.Drawing.Size(142, 23);
            this.andiImageComboBox2.TabIndex = 32;
            this.andiImageComboBox2.SelectedIndexChanged += new System.EventHandler(this.andiImageComboBox2_SelectedIndexChanged);
            //
            // label2
            //
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(11, 50);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(76, 13);
            this.label2.TabIndex = 28;
            this.label2.Text = "Requestment :";
            //
            // label3
            //
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(241, 50);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(13, 13);
            this.label3.TabIndex = 31;
            this.label3.Text = "?";
            //
            // andiImageComboBox1
            //
            this.andiImageComboBox1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
            this.andiImageComboBox1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
            this.andiImageComboBox1.FormattingEnabled = true;
            this.andiImageComboBox1.ItemHeight = 17;
            this.andiImageComboBox1.Location = new System.Drawing.Point(93, 45);
            this.andiImageComboBox1.Name = "andiImageComboBox1";
            this.andiImageComboBox1.Size = new System.Drawing.Size(142, 23);
            this.andiImageComboBox1.TabIndex = 29;
            this.andiImageComboBox1.SelectedIndexChanged += new System.EventHandler(this.andiImageComboBox1_SelectedIndexChanged);
            //
            // numericUpDown1
            //
            this.numericUpDown1.Location = new System.Drawing.Point(115, 71);
            this.numericUpDown1.Name = "numericUpDown1";
            this.numericUpDown1.Size = new System.Drawing.Size(120, 20);
            this.numericUpDown1.TabIndex = 30;
            this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
            //
            // andiGroupBox1
            //
            this.andiGroupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
            | System.Windows.Forms.AnchorStyles.Right)));
            this.andiGroupBox1.Controls.Add(this.pkm_1);
            this.andiGroupBox1.Controls.Add(this.andiImageComboBox4);
            this.andiGroupBox1.Controls.Add(this.label5);
            this.andiGroupBox1.Location = new System.Drawing.Point(4, 4);
            this.andiGroupBox1.Name = "andiGroupBox1";
            this.andiGroupBox1.Size = new System.Drawing.Size(473, 42);
            this.andiGroupBox1.TabIndex = 36;
            this.andiGroupBox1.TabStop = false;
            this.andiGroupBox1.Text = "Baby Pokemon";
            //
            // pkm_1
            //
            this.pkm_1.AutoScroll = false;
            this.pkm_1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.pkm_1.IndexParent = 0;
            this.pkm_1.Location = new System.Drawing.Point(244, 10);
            this.pkm_1.Name = "pkm_1";
            this.pkm_1.Size = new System.Drawing.Size(32, 32);
            this.pkm_1.TabIndex = 36;
            //
            // andiImageComboBox4
            //
            this.andiImageComboBox4.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
            this.andiImageComboBox4.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
            this.andiImageComboBox4.Enabled = false;
            this.andiImageComboBox4.FormattingEnabled = true;
            this.andiImageComboBox4.ItemHeight = 17;
            this.andiImageComboBox4.Location = new System.Drawing.Point(97, 15);
            this.andiImageComboBox4.Name = "andiImageComboBox4";
            this.andiImageComboBox4.Size = new System.Drawing.Size(142, 23);
            this.andiImageComboBox4.TabIndex = 35;
            this.andiImageComboBox4.SelectedIndexChanged += new System.EventHandler(this.andiImageComboBox4_SelectedIndexChanged);
            //
            // label5
            //
            this.label5.AutoSize = true;
            this.label5.Location = new System.Drawing.Point(10, 19);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(81, 13);
            this.label5.TabIndex = 34;
            this.label5.Text = "BaseEvolution :";
            //
            // tabPage2
            //
            this.tabPage2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(239)))), ((int)(((byte)(239)))), ((int)(((byte)(242)))));
            this.tabPage2.Controls.Add(this.hexBox1);
            this.tabPage2.Location = new System.Drawing.Point(4, 21);
            this.tabPage2.Name = "tabPage2";
            this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
            this.tabPage2.Size = new System.Drawing.Size(481, 402);
            this.tabPage2.TabIndex = 1;
            this.tabPage2.Text = "HEX";
            //
            // hexBox1
            //
            this.hexBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
            | System.Windows.Forms.AnchorStyles.Left)
            | System.Windows.Forms.AnchorStyles.Right)));
            this.hexBox1.ColumnInfoVisible = true;
            this.hexBox1.Font = new System.Drawing.Font("Segoe UI", 9F);
            this.hexBox1.HexCasing = HexCasing.Lower;
            this.hexBox1.LineInfoVisible = true;
            this.hexBox1.Location = new System.Drawing.Point(2, 3);
            this.hexBox1.Name = "hexBox1";
            this.hexBox1.ReadOnly = true;
            this.hexBox1.ShadowSelectionColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(60)))), ((int)(((byte)(188)))), ((int)(((byte)(255)))));
            this.hexBox1.Size = new System.Drawing.Size(475, 396);
            this.hexBox1.StringViewVisible = true;
            this.hexBox1.TabIndex = 1;
            this.hexBox1.UseFixedBytesPerLine = true;
            this.hexBox1.VScrollBarVisible = true;
            //
            // vEvolutions
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(635, 452);
            this.Controls.Add(this.splitContainer1);
            this.Controls.Add(this.toolStrip1);
            this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.Name = "vEvolutions";
            this.Text = "vEvolutions";
            this.toolStrip1.ResumeLayout(false);
            this.toolStrip1.PerformLayout();
            this.splitContainer1.Panel1.ResumeLayout(false);
            this.splitContainer1.Panel2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
            this.splitContainer1.ResumeLayout(false);
            this.andiCustomTabControl1.ResumeLayout(false);
            this.tabPage1.ResumeLayout(false);
            this.andiGroupBox2.ResumeLayout(false);
            this.andiGroupBox2.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
            this.andiGroupBox1.ResumeLayout(false);
            this.andiGroupBox1.PerformLayout();
            this.tabPage2.ResumeLayout(false);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.ToolStrip toolStrip1;
        private System.Windows.Forms.SplitContainer splitContainer1;
        private AndiListBox andiListBox1;
        private AndiCustomTabControl andiCustomTabControl1;
        private System.Windows.Forms.TabPage tabPage1;
        private System.Windows.Forms.TabPage tabPage2;
        private HexBox hexBox1;
        private AndiImageComboBox andiImageComboBox3;
        private System.Windows.Forms.Label label4;
        private AndiImageComboBox andiImageComboBox2;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.NumericUpDown numericUpDown1;
        private AndiImageComboBox andiImageComboBox1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label1;
        private SourceGrid.Grid grid1;
        private System.Windows.Forms.ToolStripButton toolStripButton1;
        private System.Windows.Forms.ToolStripButton toolStripButton2;
        private System.Windows.Forms.ToolStripLabel toolStripLabel1;
        private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
        private System.Windows.Forms.ToolStripComboBox toolStripComboBox1;
        private AndiImageComboBox andiImageComboBox4;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.ToolStripLabel toolStripLabel2;
        private System.Windows.Forms.ToolStripLabel toolStripLabel3;
        private AndiGroupBox andiGroupBox2;
        private AndiGroupBox andiGroupBox1;
        private Andi.Controls.ImageBox.AndiImageBox andiImageBox1;
        private Andi.Controls.ImageBox.AndiImageBox pkm_1;
    }
}

redpajama_set_name: RedPajamaGithub


text:
package io.celox.androiddemos.jsonlayout.model.conversation;

/**
 * @author Martin Pfeffer martin.pfeffer@kjtech.com, martin.pfeffer@celox.io
 * @see www.kjtech.de
 */

public abstract class BaseEntity {

    private int id;
    private int position;
    private String description;

    public BaseEntity(int id, int position, String description) {
        this.id = id;
        this.position = position;
        this.description = description;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getPosition() {
        return position;
    }

    public void setPosition(int position) {
        this.position = position;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    public String toString() {
        return "[" + position + "]";
    }
}


text:
package com.google.cloud.monitoring.dashboard.v1;

import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutures;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
import com.google.api.gax.paging.AbstractPagedListResponse;
import com.google.api.gax.rpc.PageContext;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.monitoring.dashboard.v1.stub.DashboardsServiceStub;
import com.google.cloud.monitoring.dashboard.v1.stub.DashboardsServiceStubSettings;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.monitoring.dashboard.v1.CreateDashboardRequest;
import com.google.monitoring.dashboard.v1.Dashboard;
import com.google.monitoring.dashboard.v1.DeleteDashboardRequest;
import com.google.monitoring.dashboard.v1.GetDashboardRequest;
import com.google.monitoring.dashboard.v1.ListDashboardsRequest;
import com.google.monitoring.dashboard.v1.ListDashboardsResponse;
import com.google.monitoring.dashboard.v1.UpdateDashboardRequest;
import com.google.protobuf.Empty;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;

// AUTO-GENERATED DOCUMENTATION AND CLASS.
/**
 * Service Description: Manages Stackdriver dashboards. A dashboard is an arrangement of data
 * display widgets in a specific layout.
 *
 *
This class provides the ability to make remote calls to the backing service through method
 * calls that map to API methods. Sample code to get started:
 *
 *
{@code
 * // This snippet has been automatically generated and should be regarded as a code template only.
 * // It will require modifications to work:
 * // - It may require correct/in-range values for request initialization.
 * // - It may require specifying regional endpoints when creating the service client as shown in
 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 * try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
 *   CreateDashboardRequest request =
 *       CreateDashboardRequest.newBuilder()
 *           .setParent("parent-995424086")
 *           .setDashboard(Dashboard.newBuilder().build())
 *           .setValidateOnly(true)
 *           .build();
 *   Dashboard response = dashboardsServiceClient.createDashboard(request);
 * }
 * }

 *
 *
Note: close() needs to be called on the DashboardsServiceClient object to clean up resources
 * such as threads. In the example above, try-with-resources is used, which automatically calls
 * close().
 *
 *
The surface of this class includes several types of Java methods for each of the API's
 * methods:
 *
 *

 *
A "flattened" method. With this type of method, the fields of the request type have been
 *       converted into function parameters. It may be the case that not all fields are available as
 *       parameters, and not every API method will have a flattened method entry point.
 *
A "request object" method. This type of method only takes one parameter, a request object,
 *       which must be constructed before the call. Not every API method will have a request object
 *       method.
 *
A "callable" method. This type of method takes no parameters and returns an immutable API
 *       callable object, which can be used to initiate calls to the service.
 *

 *
 *
See the individual methods for example code.
 *
 *
Many parameters require resource names to be formatted in a particular way. To assist with
 * these names, this class includes a format method for each type of name, and additionally a parse
 * method to extract the individual identifiers contained within names that are returned.
 *
 *
This class can be customized by passing in a custom instance of DashboardsServiceSettings to
 * create(). For example:
 *
 *
To customize credentials:
 *
 *
{@code
 * // This snippet has been automatically generated and should be regarded as a code template only.
 * // It will require modifications to work:
 * // - It may require correct/in-range values for request initialization.
 * // - It may require specifying regional endpoints when creating the service client as shown in
 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 * DashboardsServiceSettings dashboardsServiceSettings =
 *     DashboardsServiceSettings.newBuilder()
 *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
 *         .build();
 * DashboardsServiceClient dashboardsServiceClient =
 *     DashboardsServiceClient.create(dashboardsServiceSettings);
 * }

 *
 *
To customize the endpoint:
 *
 *
{@code
 * // This snippet has been automatically generated and should be regarded as a code template only.
 * // It will require modifications to work:
 * // - It may require correct/in-range values for request initialization.
 * // - It may require specifying regional endpoints when creating the service client as shown in
 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 * DashboardsServiceSettings dashboardsServiceSettings =
 *     DashboardsServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 * DashboardsServiceClient dashboardsServiceClient =
 *     DashboardsServiceClient.create(dashboardsServiceSettings);
 * }

 *
 *
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
 * the wire:
 *
 *
{@code
 * // This snippet has been automatically generated and should be regarded as a code template only.
 * // It will require modifications to work:
 * // - It may require correct/in-range values for request initialization.
 * // - It may require specifying regional endpoints when creating the service client as shown in
 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 * DashboardsServiceSettings dashboardsServiceSettings =
 *     DashboardsServiceSettings.newHttpJsonBuilder().build();
 * DashboardsServiceClient dashboardsServiceClient =
 *     DashboardsServiceClient.create(dashboardsServiceSettings);
 * }

 *
 *
Please refer to the GitHub repository's samples for more quickstart code snippets.
 */
@Generated("by gapic-generator-java")
public class DashboardsServiceClient implements BackgroundResource {
  private final DashboardsServiceSettings settings;
  private final DashboardsServiceStub stub;

  /** Constructs an instance of DashboardsServiceClient with default settings. */
  public static final DashboardsServiceClient create() throws IOException {
    return create(DashboardsServiceSettings.newBuilder().build());
  }

  /**
   * Constructs an instance of DashboardsServiceClient, using the given settings. The channels are
   * created based on the settings passed in, or defaults for any settings that are not set.
   */
  public static final DashboardsServiceClient create(DashboardsServiceSettings settings)
      throws IOException {
    return new DashboardsServiceClient(settings);
  }

  /**
   * Constructs an instance of DashboardsServiceClient, using the given stub for making calls. This
   * is for advanced usage - prefer using create(DashboardsServiceSettings).
   */
  public static final DashboardsServiceClient create(DashboardsServiceStub stub) {
    return new DashboardsServiceClient(stub);
  }

  /**
   * Constructs an instance of DashboardsServiceClient, using the given settings. This is protected
   * so that it is easy to make a subclass, but otherwise, the static factory methods should be
   * preferred.
   */
  protected DashboardsServiceClient(DashboardsServiceSettings settings) throws IOException {
    this.settings = settings;
    this.stub = ((DashboardsServiceStubSettings) settings.getStubSettings()).createStub();
  }

  protected DashboardsServiceClient(DashboardsServiceStub stub) {
    this.settings = null;
    this.stub = stub;
  }

  public final DashboardsServiceSettings getSettings() {
    return settings;
  }

  public DashboardsServiceStub getStub() {
    return stub;
  }

  // AUTO-GENERATED DOCUMENTATION AND METHOD.
  /**
   * Creates a new custom dashboard. For examples on how you can use this API to create dashboards,
   * see [Managing dashboards by API](https://cloud.google.com/monitoring/dashboards/api-dashboard).
   * This method requires the `monitoring.dashboards.create` permission on the specified project.
   * For more information about permissions, see [Cloud Identity and Access
   * Management](https://cloud.google.com/iam).
   *
   *
Sample code:
   *
   *
{@code
   * // This snippet has been automatically generated and should be regarded as a code template only.
   * // It will require modifications to work:
   * // - It may require correct/in-range values for request initialization.
   * // - It may require specifying regional endpoints when creating the service client as shown in
   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
   * try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
   *   CreateDashboardRequest request =
   *       CreateDashboardRequest.newBuilder()
   *           .setParent("parent-995424086")
   *           .setDashboard(Dashboard.newBuilder().build())
   *           .setValidateOnly(true)
   *           .build();
   *   Dashboard response = dashboardsServiceClient.createDashboard(request);
   * }
   * }

   *
   * @param request The request object containing all of the parameters for the API call.
   * @throws com.google.api.gax.rpc.ApiException if the remote call fails
   */
  public final Dashboard createDashboard(CreateDashboardRequest request) {
    return createDashboardCallable().call(request);
  }

  // AUTO-GENERATED DOCUMENTATION AND METHOD.
  /**
   * Creates a new custom dashboard. For examples on how you can use this API to create dashboards,
   * see [Managing dashboards by API](https://cloud.google.com/monitoring/dashboards/api-dashboard).
   * This method requires the `monitoring.dashboards.create` permission on the specified project.
   * For more information about permissions, see [Cloud Identity and Access
   * Management](https://cloud.google.com/iam).
   *
   *
Sample code:
   *
   *
{@code
   * // This snippet has been automatically generated and should be regarded as a code template only.
   * // It will require modifications to work:
   * // - It may require correct/in-range values for request initialization.
   * // - It may require specifying regional endpoints when creating the service client as shown in
   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
   * try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
   *   CreateDashboardRequest request =
   *       CreateDashboardRequest.newBuilder()
   *           .setParent("parent-995424086")
   *           .setDashboard(Dashboard.newBuilder().build())
   *           .setValidateOnly(true)
   *           .build();
   *   ApiFuture<Dashboard> future =
   *       dashboardsServiceClient.createDashboardCallable().futureCall(request);
   *   // Do something.
   *   Dashboard response = future.get();
   * }
   * }

   */
  public final UnaryCallable<CreateDashboardRequest, Dashboard> createDashboardCallable() {
    return stub.createDashboardCallable();
  }

  // AUTO-GENERATED DOCUMENTATION AND METHOD.
  /**
   * Lists the existing dashboards.
   *
   *
This method requires the `monitoring.dashboards.list` permission on the specified project.
   * For more information, see [Cloud Identity and Access Management](https://cloud.google.com/iam).
   *
   *
Sample code:
   *
   *
{@code
   * // This snippet has been automatically generated and should be regarded as a code template only.
   * // It will require modifications to work:
   * // - It may require correct/in-range values for request initialization.
   * // - It may require specifying regional endpoints when creating the service client as shown in
   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
   * try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
   *   ListDashboardsRequest request =
   *       ListDashboardsRequest.newBuilder()
   *           .setParent(ProjectName.of("[PROJECT]").toString())
   *           .setPageSize(883849137)
   *           .setPageToken("pageToken873572522")
   *           .build();
   *   for (Dashboard element : dashboardsServiceClient.listDashboards(request).iterateAll()) {
   *     // doThingsWith(element);
   *   }
   * }
   * }

   *
   * @param request The request object containing all of the parameters for the API call.
   * @throws com.google.api.gax.rpc.ApiException if the remote call fails
   */
  public final ListDashboardsPagedResponse listDashboards(ListDashboardsRequest request) {
    return listDashboardsPagedCallable().call(request);
  }

  // AUTO-GENERATED DOCUMENTATION AND METHOD.
  /**
   * Lists the existing dashboards.
   *
   *
This method requires the `monitoring.dashboards.list` permission on the specified project.
   * For more information, see [Cloud Identity and Access Management](https://cloud.google.com/iam).
   *
   *
Sample code:
   *
   *
{@code
   * // This snippet has been automatically generated and should be regarded as a code template only.
   * // It will require modifications to work:
   * // - It may require correct/in-range values for request initialization.
   * // - It may require specifying regional endpoints when creating the service client as shown in
   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
   * try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
   *   ListDashboardsRequest request =
   *       ListDashboardsRequest.newBuilder()
   *           .setParent(ProjectName.of("[PROJECT]").toString())
   *           .setPageSize(883849137)
   *           .setPageToken("pageToken873572522")
   *           .build();
   *   ApiFuture<Dashboard> future =
   *       dashboardsServiceClient.listDashboardsPagedCallable().futureCall(request);
   *   // Do something.
   *   for (Dashboard element : future.get().iterateAll()) {
   *     // doThingsWith(element);
   *   }
   * }
   * }

   */
  public final UnaryCallable<ListDashboardsRequest, ListDashboardsPagedResponse>
      listDashboardsPagedCallable() {
    return stub.listDashboardsPagedCallable();
  }

  // AUTO-GENERATED DOCUMENTATION AND METHOD.
  /**
   * Lists the existing dashboards.
   *
   *
This method requires the `monitoring.dashboards.list` permission on the specified project.
   * For more information, see [Cloud Identity and Access Management](https://cloud.google.com/iam).
   *
   *
Sample code:
   *
   *
{@code
   * // This snippet has been automatically generated and should be regarded as a code template only.
   * // It will require modifications to work:
   * // - It may require correct/in-range values for request initialization.
   * // - It may require specifying regional endpoints when creating the service client as shown in
   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
   * try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
   *   ListDashboardsRequest request =
   *       ListDashboardsRequest.newBuilder()
   *           .setParent(ProjectName.of("[PROJECT]").toString())
   *           .setPageSize(883849137)
   *           .setPageToken("pageToken873572522")
   *           .build();
   *   while (true) {
   *     ListDashboardsResponse response =
   *         dashboardsServiceClient.listDashboardsCallable().call(request);
   *     for (Dashboard element : response.getDashboardsList()) {
   *       // doThingsWith(element);
   *     }
   *     String nextPageToken = response.getNextPageToken();
   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
   *       request = request.toBuilder().setPageToken(nextPageToken).build();
   *     } else {
   *       break;
   *     }
   *   }
   * }
   * }

   */
  public final UnaryCallable<ListDashboardsRequest, ListDashboardsResponse>
      listDashboardsCallable() {
    return stub.listDashboardsCallable();
  }

  // AUTO-GENERATED DOCUMENTATION AND METHOD.
  /**
   * Fetches a specific dashboard.
   *
   *
This method requires the `monitoring.dashboards.get` permission on the specified dashboard.
   * For more information, see [Cloud Identity and Access Management](https://cloud.google.com/iam).
   *
   *
Sample code:
   *
   *
{@code
   * // This snippet has been automatically generated and should be regarded as a code template only.
   * // It will require modifications to work:
   * // - It may require correct/in-range values for request initialization.
   * // - It may require specifying regional endpoints when creating the service client as shown in
   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
   * try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
   *   GetDashboardRequest request =
   *       GetDashboardRequest.newBuilder()
   *           .setName(DashboardName.of("[PROJECT]", "[DASHBOARD]").toString())
   *           .build();
   *   Dashboard response = dashboardsServiceClient.getDashboard(request);
   * }
   * }

   *
   * @param request The request object containing all of the parameters for the API call.
   * @throws com.google.api.gax.rpc.ApiException if the remote call fails
   */
  public final Dashboard getDashboard(GetDashboardRequest request) {
    return getDashboardCallable().call(request);
  }

  // AUTO-GENERATED DOCUMENTATION AND METHOD.
  /**
   * Fetches a specific dashboard.
   *
   *
This method requires the `monitoring.dashboards.get` permission on the specified dashboard.
   * For more information, see [Cloud Identity and Access Management](https://cloud.google.com/iam).
   *
   *
Sample code:
   *
   *
{@code
   * // This snippet has been automatically generated and should be regarded as a code template only.
   * // It will require modifications to work:
   * // - It may require correct/in-range values for request initialization.
   * // - It may require specifying regional endpoints when creating the service client as shown in
   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
   * try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
   *   GetDashboardRequest request =
   *       GetDashboardRequest.newBuilder()
   *           .setName(DashboardName.of("[PROJECT]", "[DASHBOARD]").toString())
   *           .build();
   *   ApiFuture<Dashboard> future =
   *       dashboardsServiceClient.getDashboardCallable().futureCall(request);
   *   // Do something.
   *   Dashboard response = future.get();
   * }
   * }

   */
  public final UnaryCallable<GetDashboardRequest, Dashboard> getDashboardCallable() {
    return stub.getDashboardCallable();
  }

  // AUTO-GENERATED DOCUMENTATION AND METHOD.
  /**
   * Deletes an existing custom dashboard.
   *
   *
This method requires the `monitoring.dashboards.delete` permission on the specified
   * dashboard. For more information, see [Cloud Identity and Access
   * Management](https://cloud.google.com/iam).
   *
   *
Sample code:
   *
   *
{@code
   * // This snippet has been automatically generated and should be regarded as a code template only.
   * // It will require modifications to work:
   * // - It may require correct/in-range values for request initialization.
   * // - It may require specifying regional endpoints when creating the service client as shown in
   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
   * try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
   *   DeleteDashboardRequest request =
   *       DeleteDashboardRequest.newBuilder()
   *           .setName(DashboardName.of("[PROJECT]", "[DASHBOARD]").toString())
   *           .build();
   *   dashboardsServiceClient.deleteDashboard(request);
   * }
   * }

   *
   * @param request The request object containing all of the parameters for the API call.
   * @throws com.google.api.gax.rpc.ApiException if the remote call fails
   */
  public final void deleteDashboard(DeleteDashboardRequest request) {
    deleteDashboardCallable().call(request);
  }

  // AUTO-GENERATED DOCUMENTATION AND METHOD.
  /**
   * Deletes an existing custom dashboard.
   *
   *
This method requires the `monitoring.dashboards.delete` permission on the specified
   * dashboard. For more information, see [Cloud Identity and Access
   * Management](https://cloud.google.com/iam).
   *
   *
Sample code:
   *
   *
{@code
   * // This snippet has been automatically generated and should be regarded as a code template only.
   * // It will require modifications to work:
   * // - It may require correct/in-range values for request initialization.
   * // - It may require specifying regional endpoints when creating the service client as shown in
   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
   * try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
   *   DeleteDashboardRequest request =
   *       DeleteDashboardRequest.newBuilder()
   *           .setName(DashboardName.of("[PROJECT]", "[DASHBOARD]").toString())
   *           .build();
   *   ApiFuture<Empty> future =
   *       dashboardsServiceClient.deleteDashboardCallable().futureCall(request);
   *   // Do something.
   *   future.get();
   * }
   * }

   */
  public final UnaryCallable<DeleteDashboardRequest, Empty> deleteDashboardCallable() {
    return stub.deleteDashboardCallable();
  }

  // AUTO-GENERATED DOCUMENTATION AND METHOD.
  /**
   * Replaces an existing custom dashboard with a new definition.
   *
   *
This method requires the `monitoring.dashboards.update` permission on the specified
   * dashboard. For more information, see [Cloud Identity and Access
   * Management](https://cloud.google.com/iam).
   *
   *
Sample code:
   *
   *
{@code
   * // This snippet has been automatically generated and should be regarded as a code template only.
   * // It will require modifications to work:
   * // - It may require correct/in-range values for request initialization.
   * // - It may require specifying regional endpoints when creating the service client as shown in
   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
   * try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
   *   UpdateDashboardRequest request =
   *       UpdateDashboardRequest.newBuilder()
   *           .setDashboard(Dashboard.newBuilder().build())
   *           .setValidateOnly(true)
   *           .build();
   *   Dashboard response = dashboardsServiceClient.updateDashboard(request);
   * }
   * }

   *
   * @param request The request object containing all of the parameters for the API call.
   * @throws com.google.api.gax.rpc.ApiException if the remote call fails
   */
  public final Dashboard updateDashboard(UpdateDashboardRequest request) {
    return updateDashboardCallable().call(request);
  }

  // AUTO-GENERATED DOCUMENTATION AND METHOD.
  /**
   * Replaces an existing custom dashboard with a new definition.
   *
   *
This method requires the `monitoring.dashboards.update` permission on the specified
   * dashboard. For more information, see [Cloud Identity and Access
   * Management](https://cloud.google.com/iam).
   *
   *
Sample code:
   *
   *
{@code
   * // This snippet has been automatically generated and should be regarded as a code template only.
   * // It will require modifications to work:
   * // - It may require correct/in-range values for request initialization.
   * // - It may require specifying regional endpoints when creating the service client as shown in
   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
   * try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
   *   UpdateDashboardRequest request =
   *       UpdateDashboardRequest.newBuilder()
   *           .setDashboard(Dashboard.newBuilder().build())
   *           .setValidateOnly(true)
   *           .build();
   *   ApiFuture<Dashboard> future =
   *       dashboardsServiceClient.updateDashboardCallable().futureCall(request);
   *   // Do something.
   *   Dashboard response = future.get();
   * }
   * }

   */
  public final UnaryCallable<UpdateDashboardRequest, Dashboard> updateDashboardCallable() {
    return stub.updateDashboardCallable();
  }

  @Override
  public final void close() {
    stub.close();
  }

  @Override
  public void shutdown() {
    stub.shutdown();
  }

  @Override
  public boolean isShutdown() {
    return stub.isShutdown();
  }

  @Override
  public boolean isTerminated() {
    return stub.isTerminated();
  }

  @Override
  public void shutdownNow() {
    stub.shutdownNow();
  }

  @Override
  public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
    return stub.awaitTermination(duration, unit);
  }

  public static class ListDashboardsPagedResponse
      extends AbstractPagedListResponse<
          ListDashboardsRequest,
          ListDashboardsResponse,
          Dashboard,
          ListDashboardsPage,
          ListDashboardsFixedSizeCollection> {

    public static ApiFuture<ListDashboardsPagedResponse> createAsync(
        PageContext<ListDashboardsRequest, ListDashboardsResponse, Dashboard> context,
        ApiFuture<ListDashboardsResponse> futureResponse) {
      ApiFuture<ListDashboardsPage> futurePage =
          ListDashboardsPage.createEmptyPage().createPageAsync(context, futureResponse);
      return ApiFutures.transform(
          futurePage,
          input -> new ListDashboardsPagedResponse(input),
          MoreExecutors.directExecutor());
    }

    private ListDashboardsPagedResponse(ListDashboardsPage page) {
      super(page, ListDashboardsFixedSizeCollection.createEmptyCollection());
    }
  }

  public static class ListDashboardsPage
      extends AbstractPage<
          ListDashboardsRequest, ListDashboardsResponse, Dashboard, ListDashboardsPage> {

    private ListDashboardsPage(
        PageContext<ListDashboardsRequest, ListDashboardsResponse, Dashboard> context,
        ListDashboardsResponse response) {
      super(context, response);
    }

    private static ListDashboardsPage createEmptyPage() {
      return new ListDashboardsPage(null, null);
    }

    @Override
    protected ListDashboardsPage createPage(
        PageContext<ListDashboardsRequest, ListDashboardsResponse, Dashboard> context,
        ListDashboardsResponse response) {
      return new ListDashboardsPage(context, response);
    }

    @Override
    public ApiFuture<ListDashboardsPage> createPageAsync(
        PageContext<ListDashboardsRequest, ListDashboardsResponse, Dashboard> context,
        ApiFuture<ListDashboardsResponse> futureResponse) {
      return super.createPageAsync(context, futureResponse);
    }
  }

  public static class ListDashboardsFixedSizeCollection
      extends AbstractFixedSizeCollection<
          ListDashboardsRequest,
          ListDashboardsResponse,
          Dashboard,
          ListDashboardsPage,
          ListDashboardsFixedSizeCollection> {

    private ListDashboardsFixedSizeCollection(List<ListDashboardsPage> pages, int collectionSize) {
      super(pages, collectionSize);
    }

    private static ListDashboardsFixedSizeCollection createEmptyCollection() {
      return new ListDashboardsFixedSizeCollection(null, 0);
    }

    @Override
    protected ListDashboardsFixedSizeCollection createCollection(
        List<ListDashboardsPage> pages, int collectionSize) {
      return new ListDashboardsFixedSizeCollection(pages, collectionSize);
    }
  }
}


text:
package com.mauriciotogneri.betfair.monitors;

import com.mauriciotogneri.betfair.Constants;
import com.mauriciotogneri.betfair.api.base.Enums.EventTypeEnum;
import com.mauriciotogneri.betfair.api.base.Enums.MarketStatus;
import com.mauriciotogneri.betfair.api.base.Enums.MarketTypeEnum;
import com.mauriciotogneri.betfair.api.base.HttpClient;
import com.mauriciotogneri.betfair.api.base.Session;
import com.mauriciotogneri.betfair.api.base.Types.Event;
import com.mauriciotogneri.betfair.api.base.Types.MarketBook;
import com.mauriciotogneri.betfair.api.base.Types.MarketCatalogue;
import com.mauriciotogneri.betfair.api.base.Types.PriceSize;
import com.mauriciotogneri.betfair.api.base.Types.Runner;
import com.mauriciotogneri.betfair.api.betting.ListMarketBook;
import com.mauriciotogneri.betfair.logs.StatusLog;
import com.mauriciotogneri.betfair.models.Selection;
import com.mauriciotogneri.betfair.models.Tick;
import com.mauriciotogneri.betfair.strategies.Strategy;
import com.mauriciotogneri.betfair.utils.IoUtils;
import com.mauriciotogneri.betfair.utils.JsonUtils;
import com.mauriciotogneri.betfair.utils.NumberUtils;
import com.mauriciotogneri.betfair.utils.TimeUtils;

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

public class MarketMonitor extends AbstractMonitor
{
    private final Event event;
    private final String eventType;
    private final String marketId;
    private final String marketType;
    private final MarketCatalogue marketCatalogue;
    private final String logFolderPath;

    private StatusLog logStatus;

    private Strategy strategy;

    private ListMarketBook listMarketBook = null;
    private long eventStartTime = 0;

    private final List<Long> selections = new ArrayList<>();

    private static final int WAITING_TIME = 250; // 4 times per second (in milliseconds)

    public MarketMonitor(HttpClient httpClient, Session session, String logFolderPath, Event event, String eventType, MarketCatalogue marketCatalogue)
    {
        super(httpClient, session, "MARKET MONITOR: " + event.id + " - " + marketCatalogue.marketId);

        this.event = event;
        this.eventType = eventType;
        this.marketId = marketCatalogue.marketId;
        this.marketType = marketCatalogue.description.marketType;
        this.marketCatalogue = marketCatalogue;
        this.logFolderPath = logFolderPath;
    }

    @Override
    protected int getWaitTime()
    {
        return WAITING_TIME;
    }

    @Override
    protected boolean onPreExecute() throws Exception
    {
        IoUtils.writeFile(logFolderPath + Constants.Log.INFO_LOG_FILE, JsonUtils.toJson(marketCatalogue));

        eventStartTime = TimeUtils.dateToMilliseconds(event.openDate, "UTC");

        logStatus = new StatusLog(logFolderPath + Constants.Log.STATUS_LOG_FILE);

        listMarketBook = ListMarketBook.getRequest(httpClient, session, marketId);

        MarketBook marketBook = getMarketBook();

        if (marketBook != null)
        {
            for (Runner runner : marketBook.runners)
            {
                selections.add(runner.selectionId);
            }
        }

        strategy = Strategy.getStrategy(session, EventTypeEnum.get(eventType), MarketTypeEnum.valueOf(marketType), event.id, marketId, selections, logFolderPath);

        long currentMatchTime = getCurrentMatchTime();

        return (marketBook != null) && (strategy != null) && (currentMatchTime < 0);
    }

    @Override
    protected void onPostExecute(boolean executed) throws Exception
    {
        strategy.onClose(getCurrentMatchTime(), executed);
    }

    @Override
    protected boolean execute() throws Exception
    {
        MarketBook marketBook = getMarketBook();

        long timestamp = getCurrentMatchTime();

        if (marketBook != null)
        {
            if (marketBook.status != MarketStatus.OPEN)
            {
                logStatus.log(timestamp, marketBook.status.toString());
            }
        }

        if ((marketBook == null) || (marketBook.status == MarketStatus.CLOSED))
        {
            return false;
        }

        if (marketBook.status == MarketStatus.OPEN)
        {
            Tick tick = new Tick(timestamp);

            for (Long selectionId : selections)
            {
                double back = 0;
                double lay = 0;

                Runner runner = marketBook.getRunner(selectionId);

                if ((runner != null) && (runner.isActive()))
                {
                    PriceSize priceBack = runner.getBackValue();

                    if (priceBack != null)
                    {
                        back = NumberUtils.round(priceBack.price);
                    }

                    PriceSize priceLay = runner.getLayValue();

                    if (priceLay != null)
                    {
                        lay = NumberUtils.round(priceLay.price);
                    }
                }

                Selection selection = new Selection(back, lay);
                tick.add(selection);
            }

            return strategy.process(tick);
        }

        return true;
    }

    private long getCurrentMatchTime()
    {
        return System.currentTimeMillis() - eventStartTime;
    }

    private MarketBook getMarketBook() throws IOException
    {
        ListMarketBook.Response marketBookResponse = listMarketBook.execute();

        if (!marketBookResponse.isEmpty())
        {
            return marketBookResponse.get(0);
        }

        return null;
    }
}


text:
<?php

class Insight_Plugin_Process extends Insight_Plugin_API {

    public function console($name = 'Console') {
        return $this->message->api('Insight_Plugin_Console')->meta(array(
            'context' => 'process',
            'target' => 'console/' . $name
        ));
    }

}


text:
#include "visualizerthread.h"

VisualizerThread::VisualizerThread()
{
    update_ = new bool(false);

    update_mutex_ = boost::shared_ptr<boost::mutex>(new boost::mutex());

    viewer_ = boost::shared_ptr<pcl::visualization::PCLVisualizer>(
        new pcl::visualization::PCLVisualizer("Object Volume Estimator"));

    cloud_0_ = pcl::PointCloud<pcl::PointXYZ>::Ptr(new pcl::PointCloud<pcl::PointXYZ>);
    cloud_0_->points.clear();
    cloud_0_->points.push_back(pcl::PointXYZ(0,0,0));
    cloud_0_->width = 1;
    cloud_0_->height = 1;

    cloud_1_ = pcl::PointCloud<pcl::PointXYZ>::Ptr(new pcl::PointCloud<pcl::PointXYZ>);
    cloud_1_->points.clear();
    cloud_1_->points.push_back(pcl::PointXYZ(0,0,0));
    cloud_1_->width = 1;
    cloud_1_->height = 1;

    cloud_complete_ = pcl::PointCloud<pcl::PointXYZ>::Ptr(new pcl::PointCloud<pcl::PointXYZ>);
    cloud_complete_->points.clear();
    cloud_complete_->points.push_back(pcl::PointXYZ(0,0,0));
    cloud_complete_->width = 1;
    cloud_complete_->height = 1;

    viewer_->createViewPort (0.0, 0.0, 0.5, 0.5, v_0_);
    viewer_->setBackgroundColor (0.2, 0.2, 0.2, v_0_);
    viewer_->addText ("Camera #0", 10, 10, "v0 text", v_0_);
    viewer_->addPointCloud<pcl::PointXYZ> (cloud_0_, "object0", v_0_);
    viewer_->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "object0", v_0_);
    viewer_->addCoordinateSystem (1.0, v_0_);

    viewer_->createViewPort (0.5, 0.0, 1.0, 0.5, v_1_);
    viewer_->setBackgroundColor (0.2, 0.2, 0.2, v_1_);
    viewer_->addText ("Camera #1", 10, 10, "v1 text", v_1_);
    viewer_->addPointCloud<pcl::PointXYZ> (cloud_1_, "object1", v_1_);
    viewer_->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "object1", v_1_);
    viewer_->addCoordinateSystem (1.0, v_1_);

    viewer_->createViewPort (0.0, 0.5, 1.0, 1.0, v_complete_);
    viewer_->setBackgroundColor (0.2, 0.2, 0.2, v_complete_);
    viewer_->addText ("Complete object", 10, 10, "vcomplete text", v_complete_);
    viewer_->addPointCloud<pcl::PointXYZ> (cloud_complete_, "complete", v_complete_);
    viewer_->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "complete", v_complete_);
    viewer_->addCoordinateSystem (1.0, v_complete_);

    viewer_->setBackgroundColor (0.2, 0.2, 0.2);
    viewer_->initCameraParameters ();
    viewer_->setCameraPosition(0.3, 0.2, -0.1, 0.0, -1.0, 0.0);

    bb_ = std::shared_ptr<BoundingBox>(new BoundingBox);
}

/*unsigned int text_id = 0;
void VisualizerThread::keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event,
                                              void* viewer_void)
{
 boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer = *static_cast<boost::shared_ptr<pcl::visualization::PCLVisualizer> *> (viewer_void);
  if (event.getKeySym () == "r" && event.keyDown ())
  {
    std::cout << "r was pressed => removing all text" << std::endl;

    char str[512];
    for (unsigned int i = 0; i < text_id; ++i)
    {
      sprintf (str, "text#%03d", i);
      viewer->removeShape (str);
    }
    text_id = 0;
  }
}*/

void VisualizerThread::updateCloud(const pcl::PointCloud<pcl::PointXYZ>::Ptr &cloud,
                                   const VIEWPORT cloudName)
{
    boost::mutex::scoped_lock updateLock(*(update_mutex_.get()));
    (*update_) = true;

    if (cloudName == COMPLETE)
    {
        copyCloud(cloud, cloud_complete_);
    }
    else if (cloudName == OBJ0)
    {
        copyCloud(cloud, cloud_0_);
    }
    else if (cloudName == OBJ1)
    {
        copyCloud(cloud, cloud_1_);
    }

    //std::cout << cloud_0_->points.size() << " - " << cloud_1_->points.size() << " - " << ((*update_)?"true":"false") << std::endl;

    updateLock.unlock();
}

void VisualizerThread::copyCloud(const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &source,
                                 pcl::PointCloud<pcl::PointXYZ>::Ptr &dest)
{
    dest->clear();
    for (pcl::PointXYZ pt : source->points)
    {
        dest->points.push_back(pt);
    }
    dest->width = dest->points.size();
    dest->height = 1;
}

void VisualizerThread::updateBB(const BoundingBox &bb)
{
    bb_->max_pt = bb.max_pt;
    bb_->min_pt = bb.min_pt;
    bb_->qfinal = bb.qfinal;
    bb_->tfinal = bb.tfinal;
    //std::cout << "update bb" << bb_->max_pt.x << std::endl;
}

void VisualizerThread::operator()()
{
    // prepare visualizer named "viewer"
    while (!viewer_->wasStopped ())
    {
        viewer_->spinOnce (100);

        // Get lock on the boolean update and check if cloud was updated
        boost::mutex::scoped_lock updateLock(*(update_mutex_.get()));
        if((*update_))
        {
            //std::cout << "updating" << std::endl;
            //std::cout << cloud_0_->points.size() << " - " << cloud_1_->points.size() << " - " << ((*update_)?"true":"false") << std::endl;
            //std::cout << v_0_ << " - " << v_1_ << std::endl;

            viewer_->removeAllShapes(v_0_);
            viewer_->addText ("Camera #0", 10, 10, "v0 text", v_0_);
            if(!viewer_->updatePointCloud(cloud_0_, "object0"))
            {
                viewer_->addPointCloud<pcl::PointXYZ>(cloud_0_, "object0", v_0_);
                viewer_->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "object0", v_0_);
            }

            viewer_->removeAllShapes(v_1_);
            viewer_->addText ("Camera #1", 10, 10, "v1 text", v_1_);
            if(!viewer_->updatePointCloud(cloud_1_, "object1"))
            {
                viewer_->addPointCloud<pcl::PointXYZ>(cloud_1_, "object1", v_1_);
                viewer_->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "object1", v_1_);
            }

            viewer_->removeAllShapes(v_complete_);
            //std::cout << "try to add bb -> " << bb_->max_pt.x << std::endl;
            if (bb_)
            {
                //std::cout << "add bb" << std::endl;
                //viewer_->addCube(bb_->tfinal, bb_->qfinal,
                //            bb_->max_pt.x - bb_->min_pt.x,
                //            bb_->max_pt.y - bb_->min_pt.y,
                //            bb_->max_pt.z - bb_->min_pt.z,
                //            std::to_string(v_complete_), v_complete_);
                viewer_->addCube(bb_->min_pt.x, bb_->max_pt.x,
                                 bb_->min_pt.y, bb_->max_pt.y,
                                 bb_->min_pt.z, bb_->max_pt.z,
                                 1.0,1.0,1.0,
                                 std::to_string(v_complete_), v_complete_);
            }
            viewer_->addText ("Camera complete", 10, 10, "v complete text", v_complete_);

            if(!viewer_->updatePointCloud(cloud_complete_, "complete"))
            {
                viewer_->addPointCloud<pcl::PointXYZ>(cloud_complete_, "complete", v_complete_);
                viewer_->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "complete", v_complete_);
            }

            (*update_) = false;
        }
        updateLock.unlock();

    }
}


text:
package imj2.tools;

import static imj2.tools.BitwiseQuantizationTest.ColorTools1.min;
import static imj2.tools.BitwiseQuantizationTest.ColorTools1.packCIELAB;
import static imj2.tools.BitwiseQuantizationTest.ColorTools1.rgbToRGB;
import static imj2.tools.BitwiseQuantizationTest.ColorTools1.rgbToXYZ;
import static imj2.tools.BitwiseQuantizationTest.ColorTools1.xyzToCIELAB;
import static imj2.tools.MultiresolutionSegmentationTest.nextLOD;
import static java.lang.Math.abs;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.util.Arrays.fill;
import static multij.swing.SwingTools.show;
import static multij.tools.Tools.debug;
import static multij.tools.Tools.debugPrint;
import static multij.tools.Tools.getOrCreate;

import imj2.tools.BitwiseQuantizationTest.ColorQuantizer;
import imj2.tools.Image2DComponent.Painter;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;

import multij.tools.Canvas;
import multij.tools.Factory.DefaultFactory;
import multij.tools.TicToc;
import multij.tools.Tools;

import org.junit.Test;

/**
 * @author codistmonk (creation 2014-04-11)
 */
public final class HighSegmentationLowLabelingTest {

	@Test
	public final void test() {
		final Color contourColor = Color.GREEN;

		final SimpleImageView imageView = new SimpleImageView();

		imageView.getPainters().add(new Painter<SimpleImageView>() {

			private Canvas labels0 = new Canvas();

			private Canvas labels1 = new Canvas();

			private Canvas labels2 = new Canvas();

			private BufferedImage image0;

			private BufferedImage image1;

			private BufferedImage image2;

			@Override
			public final void paint(final Graphics2D g, final SimpleImageView component,
					final int width, final int height) {

				final TicToc timer = new TicToc();

				debugPrint("Initializing...", new Date(timer.tic()));

				final ColorQuantizer quantizer = BitwiseQuantizationTest.quantizers.get(17);

				if (this.image0 != imageView.getImage()) {
					this.image0 = imageView.getImage();
				}

				this.image1 = nextLOD(this.image0);
				this.image2 = nextLOD(this.image1);

				final int w0 = this.image0.getWidth();
				final int h0 = this.image0.getHeight();

				if (false) {
					for (int y = 0; y < h0; ++y) {
						for (int x = 0; x < w0; ++x) {
							final int[] rgb = rgbToRGB(this.image0.getRGB(x, y), new int[3]);
							final float[] cielab = xyzToCIELAB(rgbToXYZ(rgb, new float[3]));

							imageView.getBufferImage().setRGB(x, y, packCIELAB(cielab));
						}
					}

					return;
				}

				final int w1 = this.image1.getWidth();
				final int h1 = this.image1.getHeight();
				final int w2 = this.image2.getWidth();
				final int h2 = this.image2.getHeight();

				this.labels0.setFormat(w0, h0, BufferedImage.TYPE_3BYTE_BGR);
				this.labels1.setFormat(w1, h1, BufferedImage.TYPE_3BYTE_BGR);
				this.labels2.setFormat(w2, h2, BufferedImage.TYPE_3BYTE_BGR);

				this.pack(this.image0, quantizer, this.labels0.getImage());
				this.pack(this.image1, quantizer, this.image1);
				this.pack(this.image2, quantizer, this.image2);

//				SwingTools.show(this.image2, "LOD2", false);

				debugPrint(timer.toc());

				debugPrint("Labeling...", new Date(timer.tic()));

				this.setLabels(this.labels0.getImage());

				debugPrint(timer.toc());

				debugPrint("Collecting texture distributions...", new Date(timer.tic()));

				final int windowSize = 3;
				final int[] histogram = new int[quantizer.getBinCount()];
				final int[][] binHistograms = computeBinHistograms(this.image1, histogram, windowSize);

				debugPrint(timer.toc());

				debugPrint("Clustering texture distributions...", new Date(timer.tic()));

				final int[] quantas = repeat(histogram.length, windowSize * windowSize);

				debugPrint(Arrays.toString(quantas));
				reduce(quantas, binHistograms, histogram.length * windowSize * windowSize - 30);
				debugPrint(Arrays.toString(quantas));

				debugPrint(timer.toc());

				debugPrint("Quantizing textures...", new Date(timer.tic()));

				this.quantize(this.image1, windowSize, histogram, quantas, this.labels1.getImage());

//				SwingTools.show(this.labels2.getImage(), "LOD2", false);

				debugPrint(timer.toc());

				debugPrint("Applying textures...", new Date(timer.tic()));

				this.adjustLabels(this.labels1.getImage(), this.labels0.getImage());

//				SwingTools.show(this.labels0.getImage(), "LOD0", false);

				debugPrint(timer.toc());

				debugPrint("Drawing...", new Date(timer.tic()));

				this.drawContours(contourColor, imageView.getBufferImage());

//				for (int y = 0; y < this.labels2.getHeight(); ++y) {
//					for (int x = 0; x < this.labels2.getWidth(); ++x) {
//						imageView.getBufferGraphics().setColor(new Color(0xFF000000 | (this.labels2.getImage().getRGB(x, y))));
//						imageView.getBufferGraphics().drawRect(x * 4, y * 4, 4, 4);
//					}
//				}

				debugPrint(timer.toc());
			}

			private final void quantize(final BufferedImage source,
					final int windowSize, final int[] histogram, final int[] quantas,
					final BufferedImage target) {
				final int w = target.getWidth();
				final int h = target.getHeight();
				final Map<String, Integer> quantizedHistogramIds = new HashMap<String, Integer>();

				for (int y = 0; y + windowSize <= h; ++y) {
					for (int x = 0; x + windowSize <= w; ++x) {
						computeHistogram(source, x, y, windowSize, windowSize, histogram);
						final int label = quantize(histogram, windowSize * windowSize, quantas, quantizedHistogramIds);
//						final int label = this.image1.getRGB(x, y);
						target.setRGB(x, y, label);

//						imageView.getBufferImage().setRGB(2 * x + 0, 2 * y + 0, label << 3);
//						imageView.getBufferImage().setRGB(2 * x + 1, 2 * y + 0, label << 3);
//						imageView.getBufferImage().setRGB(2 * x + 0, 2 * y + 1, label << 3);
//						imageView.getBufferImage().setRGB(2 * x + 1, 2 * y + 1, label << 3);
					}
				}
			}

			private final int[][] computeBinHistograms(final BufferedImage quantizedImage, final int[] histogram, final int windowSize) {
				final int w = quantizedImage.getWidth();
				final int h = quantizedImage.getHeight();
				final int[][] result = new int[histogram.length][windowSize * windowSize + 1];

				for (int y = 0; y + windowSize <= h; ++y) {
					for (int x = 0; x + windowSize <= w; ++x) {
						computeHistogram(quantizedImage, x, y, windowSize, windowSize, histogram);

						for (int i = 0; i < histogram.length; ++i) {
							++result[i][histogram[i]];
						}
					}
				}

				return result;
			}

			private final int quantize(final int[] histogram, final int pixelCount, final int[] quantas, final Map<String, Integer> quantizedHistogramIds) {
				final int n = histogram.length;
				String key = "";

				for (int i = 0; i < n; ++i) {
					key += (histogram[i] * quantas[i] / pixelCount) + " ";
				}

				Integer result = quantizedHistogramIds.get(key);

				if (result == null) {
					result = quantizedHistogramIds.size();
					quantizedHistogramIds.put(key, result);
				}

				return result;
			}

			private final int[] repeat(final int n, final int value) {
				final int[] result = new int[n];

				fill(result, value);

				return result;
			}

			private final void reduce(final int[] quantas, final int[][] binHistograms, final int amount) {
				final int n = quantas.length;

				for (int j = 0; j < amount; ++j) {
					double minimumError = Double.POSITIVE_INFINITY;
					int index = -1;

					for (int i = 0; i < n; ++i) {
						if (0 < quantas[i]) {
							final double e = this.computeQuantizationError(binHistograms, i, quantas[i] - 1);

							if (e < minimumError) {
								minimumError = e;
								index = i;
							}
						}
					}

					if (0 <= index) {
						--quantas[index];
					} else {
						break;
					}
				}
			}

			private final double computeQuantizationError(final int[][] binHistogram, final int bin, final int quanta) {
				double result = 0.0;

				final int max = binHistogram[bin].length - 1;

				for (int i = 0; i <= max; ++i) {
					final int value = binHistogram[bin][i];
					final int quantizedValue = value * quanta / max;
					result += abs(quantizedValue - value);
				}

				return result;
			}

			private final void drawContours(final Color contourColor, final BufferedImage buffer) {
				final int w = buffer.getWidth();
				final int h = buffer.getHeight();

				for (int y = 0; y < h; ++y) {
					for (int x = 0; x < w; ++x) {
						int north = 0;
						int west = 0;
						int east = 0;
						int south = 0;

						if (0 < y) {
							north = this.labels0.getImage().getRGB(x, y - 1);
						}

						if (0 < x) {
							west = this.labels0.getImage().getRGB(x - 1, y);
						}

						if (x + 1 < w) {
							east = this.labels0.getImage().getRGB(x + 1, y);
						}

						if (y + 1 < h) {
							south = this.labels0.getImage().getRGB(x, y + 1);
						}

						final int center = this.labels0.getImage().getRGB(x, y);

						if (min(north, west, east, south) < center) {
							buffer.setRGB(x, y, contourColor.getRGB());
						}
					}
				}
			}

			private void setLabels(final BufferedImage image) {
				final int w = image.getWidth();
				final int h = image.getHeight();
				final SchedulingData schedulingData = new SchedulingData();
				int totalPixelCount = 0;

				for (int y = 0, pixel = 0, labelId = 0xFF000000; y < h; ++y) {
					for (int x = 0; x < w; ++x, ++pixel) {
						if (!schedulingData.getDone().get(pixel)) {
							schedulingData.getTodo().add(pixel);

							final int rgb = image.getRGB(x, y);

							for (int i = 0; i < schedulingData.getTodo().size(); ++i) {
								final int p = schedulingData.getTodo().get(i);

								image.setRGB(p % w, p / w, labelId);
								this.process(w, h, schedulingData, p % w, p / w, p, rgb);
							}

							final int componentPixelCount = schedulingData.getTodo().size();

							++labelId;
							totalPixelCount += componentPixelCount;

							schedulingData.getTodo().clear();
						}
					}
				}

				schedulingData.getDone().clear();

				if (w * h != totalPixelCount) {
					System.err.println(debug(Tools.DEBUG_STACK_OFFSET, "Error:", "expected:", w * h, "actual:", totalPixelCount));
				}
			}

			private void adjustLabels(final BufferedImage source, final BufferedImage target) {
				final SchedulingData schedulingData = new SchedulingData();
				final DefaultFactory<AtomicInteger> factory = DefaultFactory.forClass(AtomicInteger.class);
				final int w = target.getWidth();
				final int h = target.getHeight();
				final int s = target.getWidth() / source.getWidth();

				for (int y = 0, pixel = 0; y < h; ++y) {
					for (int x = 0; x < w; ++x, ++pixel) {
						if (!schedulingData.getDone().get(pixel)) {
							schedulingData.getTodo().add(pixel);

							final int rgb = target.getRGB(x, y);

							for (int i = 0; i < schedulingData.getTodo().size(); ++i) {
								final int p = schedulingData.getTodo().get(i);

								this.process(w, h, schedulingData, p % w, p / w, p, rgb);
							}

							final Map<Integer, AtomicInteger> lowLabeling = new HashMap<Integer, AtomicInteger>();

							for (int i = 0; i < schedulingData.getTodo().size(); ++i) {
								final int p = schedulingData.getTodo().get(i);
								final int xx = (p % w) / s;
								final int yy = (p / w) / s;

								if (xx < source.getWidth() && yy < source.getHeight()) {
									getOrCreate(lowLabeling, source.getRGB(xx, yy), factory).incrementAndGet();
								}
							}

							int newLabel = rgb;
							int newLabelCount = 0;

							for (final Map.Entry<Integer, AtomicInteger> entry : lowLabeling.entrySet()) {
								final int count = entry.getValue().get();

								if (newLabelCount < count) {
									newLabelCount = count;
									newLabel = entry.getKey();
								}
							}

							for (int i = 0; i < schedulingData.getTodo().size(); ++i) {
								final int p = schedulingData.getTodo().get(i);
								target.setRGB(p % w, p / w, newLabel);
							}

							schedulingData.getTodo().clear();
						}
					}
				}
			}

			private final void pack(final BufferedImage image, final ColorQuantizer quantizer, final BufferedImage labels) {
				final int w = image.getWidth();
				final int h = image.getHeight();

				for (int y = 0; y < h; ++y) {
					for (int x = 0; x < w; ++x) {
						labels.setRGB(x, y, quantizer.pack(image.getRGB(x, y)));
					}
				}
			}

			private final void process(final int w, final int h,
					final SchedulingData schedulingData, final int x, final int y,
					final int pixel, final int labelRGB) {
				schedulingData.getDone().set(pixel);

				if (0 < y && this.labels0.getImage().getRGB(x, y - 1) == labelRGB) {
					final int neighbor = pixel - w;

					if (!schedulingData.getDone().get(neighbor)) {
						schedulingData.getDone().set(neighbor);
						schedulingData.getTodo().add(neighbor);
					}
				}

				if (0 < x && this.labels0.getImage().getRGB(x - 1, y) == labelRGB) {
					final int neighbor = pixel - 1;

					if (!schedulingData.getDone().get(neighbor)) {
						schedulingData.getDone().set(neighbor);
						schedulingData.getTodo().add(neighbor);
					}
				}

				if (x + 1 < w && this.labels0.getImage().getRGB(x + 1, y) == labelRGB) {
					final int neighbor = pixel + 1;

					if (!schedulingData.getDone().get(neighbor)) {
						schedulingData.getDone().set(neighbor);
						schedulingData.getTodo().add(neighbor);
					}
				}

				if (y + 1 < h && this.labels0.getImage().getRGB(x, y + 1) == labelRGB) {
					final int neighbor = pixel + w;

					if (!schedulingData.getDone().get(neighbor)) {
						schedulingData.getDone().set(neighbor);
						schedulingData.getTodo().add(neighbor);
					}
				}
			}

			/**
			 * {@value}.
			 */
			private static final long serialVersionUID = -5115463345876567457L;

		});

		show(imageView, this.getClass().getSimpleName(), true);
	}

	public static final int[] computeHistogram(final BufferedImage image,
			final int x, final int y, final int width, final int height, final int[] result) {
		fill(result, 0);

		final int firstY = max(0, y);
		final int lastY = min(image.getHeight() - 1, y + height - 1);
		final int firstX = max(0, x);
		final int lastX= min(image.getWidth() - 1, x + width - 1);

		for (int yy = firstY; yy <= lastY; ++yy) {
			for (int xx = firstX; xx <= lastX; ++xx) {
				++result[0x00FFFFFF & image.getRGB(xx, yy)];
			}
		}

		return result;
	}

}