<commit_before>/*
 * Copyright (c) 2007 Pentaho Corporation.  All rights reserved. 
 * This software was developed by Pentaho Corporation and is provided under the terms 
 * of the GNU Lesser General Public License, Version 2.1. You may not use 
 * this file except in compliance with the license. If you need a copy of the license, 
 * please go to http://www.gnu.org/licenses/lgpl-2.1.txt. The Original Code is Pentaho 
 * Data Integration.  The Initial Developer is Pentaho Corporation.
 *
 * Software distributed under the GNU Lesser Public License is distributed on an "AS IS" 
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to 
 * the license for the specific language governing your rights and limitations.
*/
package org.pentaho.di.trans;

import java.util.List;
import java.util.Map;

import org.pentaho.di.core.Const;
import org.pentaho.di.core.NotePadMeta;
import org.pentaho.di.core.gui.AreaOwner;
import org.pentaho.di.core.gui.BasePainter;
import org.pentaho.di.core.gui.GCInterface;
import org.pentaho.di.core.gui.Point;
import org.pentaho.di.core.gui.Rectangle;
import org.pentaho.di.core.gui.ScrollBarInterface;
import org.pentaho.di.core.gui.AreaOwner.AreaType;
import org.pentaho.di.core.gui.GCInterface.EColor;
import org.pentaho.di.core.gui.GCInterface.EFont;
import org.pentaho.di.core.gui.GCInterface.EImage;
import org.pentaho.di.core.gui.GCInterface.ELineStyle;
import org.pentaho.di.i18n.BaseMessages;
import org.pentaho.di.partition.PartitionSchema;
import org.pentaho.di.trans.step.BaseStepData.StepExecutionStatus;
import org.pentaho.di.trans.step.StepIOMetaInterface;
import org.pentaho.di.trans.step.StepInterface;
import org.pentaho.di.trans.step.StepMeta;
import org.pentaho.di.trans.step.StepPartitioningMeta;
import org.pentaho.di.trans.step.StepStatus;
import org.pentaho.di.trans.step.errorhandling.StreamInterface;
import org.pentaho.di.trans.step.errorhandling.StreamInterface.StreamType;


public class TransPainter extends BasePainter
{
	
	private static Class<?> PKG = TransPainter.class; // for i18n purposes, needed by Translator2!!   $NON-NLS-1$
	
    public static final String STRING_PARTITIONING_CURRENT_STEP = "PartitioningCurrentStep"; // $NON-NLS-1$
	public static final String STRING_REMOTE_INPUT_STEPS        = "RemoteInputSteps";        // $NON-NLS-1$
	public static final String STRING_REMOTE_OUTPUT_STEPS       = "RemoteOutputSteps";       // $NON-NLS-1$
	public static final String STRING_STEP_ERROR_LOG            = "StepErrorLog";            // $NON-NLS-1$
	public static final String STRING_HOP_TYPE_COPY             = "HopTypeCopy";             // $NON-NLS-1$
	
	public static final String[] magnificationDescriptions = 
		new String[] { "  200% ", "  150% ", "  100% ", "  75% ", "  50% ", "  25% "};
	
	
    private TransMeta    transMeta;

    private TransHopMeta candidate;
    
	private Map<StepMeta, String> stepLogMap;
	private List<StepMeta>	mouseOverSteps;
	private StepMeta    startHopStep;
	private Point       endHopLocation;
	private StepMeta    endHopStep;
	private StepMeta       noInputStep;
	private StreamType	candidateHopType;
	private boolean 	startErrorHopStep;
	private StepMeta showTargetStreamsStep;
	private Trans trans;
	private boolean slowStepIndicatorEnabled;

    public TransPainter(GCInterface gc, TransMeta transMeta, 
                        Point area, 
                        ScrollBarInterface hori, ScrollBarInterface vert, 
                        TransHopMeta candidate, Point drop_candidate, Rectangle selrect,
                        List<AreaOwner> areaOwners, 
                        List<StepMeta> mouseOverSteps,     		
                        int iconsize, int linewidth, int gridsize, int shadowSize, boolean antiAliasing, 
                		String noteFontName, int noteFontHeight, Trans trans, boolean slowStepIndicatorEnabled
                        )
    {
    	super(gc, transMeta, area, hori, vert, drop_candidate, selrect, areaOwners,
        		iconsize, linewidth, gridsize, shadowSize, antiAliasing, 
        		noteFontName, noteFontHeight
    		);
        this.transMeta      = transMeta;
        
        this.candidate      = candidate;
        
        this.mouseOverSteps  = mouseOverSteps;
        
        this.trans = trans;
        this.slowStepIndicatorEnabled = slowStepIndicatorEnabled;        
        
        stepLogMap = null;
    }
    
    private static String[] getPeekTitles(){
		String[] titles = {
				
			BaseMessages.getString(PKG, "PeekMetric.Column.Copynr"),
			BaseMessages.getString(PKG, "PeekMetric.Column.Read"),
			BaseMessages.getString(PKG, "PeekMetric.Column.Written"),
			BaseMessages.getString(PKG, "PeekMetric.Column.Input"),
			BaseMessages.getString(PKG, "PeekMetric.Column.Output"),
			BaseMessages.getString(PKG, "PeekMetric.Column.Updated"),
			BaseMessages.getString(PKG, "PeekMetric.Column.Rejected"),
			BaseMessages.getString(PKG, "PeekMetric.Column.Errors"),
			BaseMessages.getString(PKG, "PeekMetric.Column.Active"),
			BaseMessages.getString(PKG, "PeekMetric.Column.Time"),
			BaseMessages.getString(PKG, "PeekMetric.Column.Speed"),
			BaseMessages.getString(PKG, "PeekMetric.Column.PriorityBufferSizes")						
		};
		return titles;
    }    

    public void buildTransformationImage()
    {        
        Point max   = transMeta.getMaximum();
        Point thumb = getThumb(area, max);
        offset = getOffset(thumb, area);

        // First clear the image in the background color
        gc.setBackground(EColor.BACKGROUND);
        gc.fillRectangle(0, 0, area.x, area.y);
        
        // If there is a shadow, we draw the transformation first with an alpha setting<commit_msg>4.0, 4.1 API compatibility fix.<commit_after>/*
 * Copyright (c) 2007 Pentaho Corporation.  All rights reserved. 
 * This software was developed by Pentaho Corporation and is provided under the terms 
 * of the GNU Lesser General Public License, Version 2.1. You may not use 
 * this file except in compliance with the license. If you need a copy of the license, 
 * please go to http://www.gnu.org/licenses/lgpl-2.1.txt. The Original Code is Pentaho 
 * Data Integration.  The Initial Developer is Pentaho Corporation.
 *
 * Software distributed under the GNU Lesser Public License is distributed on an "AS IS" 
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to 
 * the license for the specific language governing your rights and limitations.
*/
package org.pentaho.di.trans;

import java.util.List;
import java.util.Map;

import org.pentaho.di.core.Const;
import org.pentaho.di.core.NotePadMeta;
import org.pentaho.di.core.gui.AreaOwner;
import org.pentaho.di.core.gui.BasePainter;
import org.pentaho.di.core.gui.GCInterface;
import org.pentaho.di.core.gui.Point;
import org.pentaho.di.core.gui.Rectangle;
import org.pentaho.di.core.gui.ScrollBarInterface;
import org.pentaho.di.core.gui.AreaOwner.AreaType;
import org.pentaho.di.core.gui.GCInterface.EColor;
import org.pentaho.di.core.gui.GCInterface.EFont;
import org.pentaho.di.core.gui.GCInterface.EImage;
import org.pentaho.di.core.gui.GCInterface.ELineStyle;
import org.pentaho.di.i18n.BaseMessages;
import org.pentaho.di.partition.PartitionSchema;
import org.pentaho.di.trans.step.BaseStepData.StepExecutionStatus;
import org.pentaho.di.trans.step.StepIOMetaInterface;
import org.pentaho.di.trans.step.StepInterface;
import org.pentaho.di.trans.step.StepMeta;
import org.pentaho.di.trans.step.StepPartitioningMeta;
import org.pentaho.di.trans.step.StepStatus;
import org.pentaho.di.trans.step.errorhandling.StreamInterface;
import org.pentaho.di.trans.step.errorhandling.StreamInterface.StreamType;


public class TransPainter extends BasePainter
{
	
	private static Class<?> PKG = TransPainter.class; // for i18n purposes, needed by Translator2!!   $NON-NLS-1$
	
    public static final String STRING_PARTITIONING_CURRENT_STEP = "PartitioningCurrentStep"; // $NON-NLS-1$
	public static final String STRING_REMOTE_INPUT_STEPS        = "RemoteInputSteps";        // $NON-NLS-1$
	public static final String STRING_REMOTE_OUTPUT_STEPS       = "RemoteOutputSteps";       // $NON-NLS-1$
	public static final String STRING_STEP_ERROR_LOG            = "StepErrorLog";            // $NON-NLS-1$
	public static final String STRING_HOP_TYPE_COPY             = "HopTypeCopy";             // $NON-NLS-1$
	
	public static final String[] magnificationDescriptions = 
		new String[] { "  200% ", "  150% ", "  100% ", "  75% ", "  50% ", "  25% "};
	
	
    private TransMeta    transMeta;

    private TransHopMeta candidate;
    
	private Map<StepMeta, String> stepLogMap;
	private List<StepMeta>	mouseOverSteps;
	private StepMeta    startHopStep;
	private Point       endHopLocation;
	private StepMeta    endHopStep;
	private StepMeta       noInputStep;
	private StreamType	candidateHopType;
	private boolean 	startErrorHopStep;
	private StepMeta showTargetStreamsStep;
	private Trans trans;
	private boolean slowStepIndicatorEnabled;

    public TransPainter(GCInterface gc, TransMeta transMeta, 
                        Point area, 
                        ScrollBarInterface hori, ScrollBarInterface vert, 
                        TransHopMeta candidate, Point drop_candidate, Rectangle selrect,
                        List<AreaOwner> areaOwners, 
                        List<StepMeta> mouseOverSteps,     		
                        int iconsize, int linewidth, int gridsize, int shadowSize, boolean antiAliasing, 
                		String noteFontName, int noteFontHeight, Trans trans, boolean slowStepIndicatorEnabled
                        )
    {
    	super(gc, transMeta, area, hori, vert, drop_candidate, selrect, areaOwners,
        		iconsize, linewidth, gridsize, shadowSize, antiAliasing, 
        		noteFontName, noteFontHeight
    		);
        this.transMeta      = transMeta;
        
        this.candidate      = candidate;
        
        this.mouseOverSteps  = mouseOverSteps;
        
        this.trans = trans;
        this.slowStepIndicatorEnabled = slowStepIndicatorEnabled;        
        
        stepLogMap = null;
    }
    
  public TransPainter(GCInterface gc, TransMeta transMeta, Point area, ScrollBarInterface hori, ScrollBarInterface vert, 
      TransHopMeta candidate, Point drop_candidate, Rectangle selrect, List<AreaOwner> areaOwners, List<StepMeta> mouseOverSteps,
      int iconsize, int linewidth, int gridsize, int shadowSize, boolean antiAliasing, String noteFontName, int noteFontHeight, Trans trans) {
    
    this(gc, transMeta, area, hori, vert, candidate, drop_candidate, selrect, areaOwners, mouseOverSteps, iconsize, linewidth, gridsize, shadowSize, 
        antiAliasing, noteFontName, noteFontHeight, trans, false);
  }
    
    private static String[] getPeekTitles(){
		String[] titles = {
				
			BaseMessages.getString(PKG, "PeekMetric.Column.Copynr"),
			BaseMessages.getString(PKG, "PeekMetric.Column.Read"),
			BaseMessages.getString(PKG, "PeekMetric.Column.Written"),
			BaseMessages.getString(PKG, "PeekMetric.Column.Input"),
			BaseMessages.getString(PKG, "PeekMetric.Column.Output"),
			BaseMessages.getString(PKG, "PeekMetric.Column.Updated"),
			BaseMessages.getString(PKG, "PeekMetric.Column.Rejected"),
			BaseMessages.getString(PKG, "PeekMetric.Column.Errors"),
			BaseMessages.getString(PKG, "PeekMetric.Column.Active"),
			BaseMessages.getString(PKG, "PeekMetric.Column.Time"),
			BaseMessages.getString(PKG, "PeekMetric.Column.Speed"),
			BaseMessages.getString(PKG, "PeekMetric.Column.PriorityBufferSizes")						
		};
		return titles;
    }    

    public void buildTransformationImage()
    {        
        Point max   = transMeta.getMaximum();
        Point thumb = getThumb(area, max);
        offset = getOffset(thumb, area);

        // First clear the image in the background color
        gc.setBackground(EColor.BACKGROUND);
        gc.fillRectangle(0, 0, area.x, area.y);
        
        // If there is a shadow, we draw the transformation first with an alpha setting
{'fraction_non_alphanumeric': 0.09222333000997009, 'fraction_numerical': 0.006314390162844799, 'mean_word_length': 3.2684397163120567, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4218197', 'n_tokens_mistral': 3764, 'n_tokens_neox': 3516, 'n_words': 861}