<commit_before>package org.xtuml.bp.ui.canvas;
//=====================================================================
//
//File:      $RCSfile: Gr_c.java,v $
//Version:   $Revision: 1.39 $
//Modified:  $Date: 2013/01/10 23:19:00 $
//
//(c) Copyright 2004-2014 Mentor Graphics Corporation All rights reserved.
//
//=====================================================================
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License.  You may obtain a copy
// of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   See the
// License for the specific language governing permissions and limitations under
// the License.
//=====================================================================
//
// This class implements the realized code for the 'Graphics (GR)'
// External Entity.
//
import org.eclipse.jface.preference.JFacePreferences;
import org.eclipse.jface.resource.FontDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.TextStyle;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.ScrollBar;

import org.xtuml.bp.core.CorePlugin;
import org.xtuml.bp.core.Justification_c;
import org.xtuml.bp.core.Style_c;
// Graphics Platform
public class Gr_c {
  public static Canvas cur_canvas = null;
  public static Model_c cur_model = null;

  private static int[] triangle = null;
  private static int[] openArrow = null;
  private static int[] cross;
  private static int lastX = 0;
  private static int lastY = 0;
  public static void Setlastx(int value) {
    Gr_c.lastX = value;
  }
  public static void Setlasty(int value) {
    Gr_c.lastY = value;
  }
  public static void Drawtext(final GCDelegate Context, final int Justified_to, final String Text, final int Text_style, final int X, final int Y) {
    // TODO #4859 there needs to be a case here to handle all of our supported text styles found in
    // the Style EDT
	// Current cases should be changed to use the TextLayout/TextStyle ala UNDERLINED below.
    String[] toPrint = Text.split("\n");  //$NON-NLS-1$
    int yOffset = 0;
    if (Justified_to == Justification_c.Center_in_X) {
      for (int i = 0; i < toPrint.length; i++) {
        int width = Scale(Context.textExtent(toPrint[i]).x);
        Context.drawText(toPrint[i], (int) ((X - (width / 2)) * m_ZoomFactor), (int) ((Y + yOffset) * m_ZoomFactor), true);
        yOffset = yOffset + Scale(Context.textExtent(toPrint[i]).y);
      }
    } else if (Justified_to == Justification_c.Center) {
      // Start by Centering the text block in the y axis
      yOffset = -Scale(Context.textExtent(Text).y) / 2;
      for (int i = 0; i < toPrint.length; i++) {
        int width = Scale(Context.textExtent(toPrint[i]).x);
        Context.drawText(toPrint[i], (int) ((X - (width / 2)) * m_ZoomFactor), (int) ((Y + yOffset) * m_ZoomFactor), true);
        yOffset = yOffset + Scale(Context.textExtent(toPrint[i]).y);
      }
    } else if (Justified_to == Justification_c.Right) {
      for (int i = 0; i < toPrint.length; i++) {
        int width = Scale(Context.textExtent(toPrint[i]).x);
        Context.drawText(toPrint[i], (int) ((X - width) * m_ZoomFactor), (int) ((Y + yOffset) * m_ZoomFactor), true);
        yOffset = yOffset + Scale(Context.textExtent(toPrint[i]).y);
      }
    } else {
      if ( Style_c.Underlined == Text_style ) {
        final TextStyle style = new TextStyle();
        style.font = Context.getFont();
        style.underline = true;
        Context.drawTextLayout(Text, (int) (X * m_ZoomFactor), (int) (Y * m_ZoomFactor), false, style);
      }
      else
      {
        Context.drawText(Text, (int) (X * m_ZoomFactor), (int) (Y * m_ZoomFactor), true);
      }
    }
  } // End drawText
  public static void Drawrect(final GCDelegate Context, boolean filled, final int H, final int W, final int X, final int Y) {
    if (filled) {
    	Context.fillRectangle((int) (X * m_ZoomFactor), (int) (Y * m_ZoomFactor), (int) (W * m_ZoomFactor), (int) (H * m_ZoomFactor));
    }
    Context.drawRectangle((int) (X * m_ZoomFactor), (int) (Y * m_ZoomFactor), (int) (W * m_ZoomFactor), (int) (H * m_ZoomFactor));
  } // End drawRect
  public static void Clipto(final GCDelegate Context, final int H, final int W, final int X, final int Y) {
    Context.setClipping((int) (X * m_ZoomFactor), (int) (Y * m_ZoomFactor), (int) (W * m_ZoomFactor), (int) (H * m_ZoomFactor));
  } // End clipTo
  public static int Gettextextent(final int Axis, final GCDelegate Context, final String Text) {
  	if ( Context == null )
  	{   
		return 0;
  	} 
    Point extent = Context.textExtent(Text);
    if (Axis == Axis_c.X)
      return Scale(extent.x);
    else
      return Scale(extent.y);<commit_msg>job #10227 Moved underline application out of justification conditional.<commit_after>package org.xtuml.bp.ui.canvas;
//=====================================================================
//
//File:      $RCSfile: Gr_c.java,v $
//Version:   $Revision: 1.39 $
//Modified:  $Date: 2013/01/10 23:19:00 $
//
//(c) Copyright 2004-2014 Mentor Graphics Corporation All rights reserved.
//
//=====================================================================
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License.  You may obtain a copy
// of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   See the
// License for the specific language governing permissions and limitations under
// the License.
//=====================================================================
//
// This class implements the realized code for the 'Graphics (GR)'
// External Entity.
//
import org.eclipse.jface.preference.JFacePreferences;
import org.eclipse.jface.resource.FontDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.TextStyle;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.ScrollBar;

import org.xtuml.bp.core.CorePlugin;
import org.xtuml.bp.core.Justification_c;
import org.xtuml.bp.core.Style_c;
// Graphics Platform
public class Gr_c {
  public static Canvas cur_canvas = null;
  public static Model_c cur_model = null;

  private static int[] triangle = null;
  private static int[] openArrow = null;
  private static int[] cross;
  private static int lastX = 0;
  private static int lastY = 0;
  public static void Setlastx(int value) {
    Gr_c.lastX = value;
  }
  public static void Setlasty(int value) {
    Gr_c.lastY = value;
  }
  public static void Drawtext(final GCDelegate Context, final int Justified_to, final String Text, final int Text_style, final int X, final int Y) {
    // TODO: Current cases should be changed to use the TextLayout/TextStyle 
    // ala UNDERLINED below.
    if ( Style_c.Underlined == Text_style ) {
      final TextStyle style = new TextStyle();
      style.font = Context.getFont();
      style.underline = true;
      Context.drawTextLayout(Text, (int) (X * m_ZoomFactor), (int) (Y * m_ZoomFactor), false, style);
    }
    String[] toPrint = Text.split("\n");  //$NON-NLS-1$
    int yOffset = 0;
    if (Justified_to == Justification_c.Center_in_X) {
      for (int i = 0; i < toPrint.length; i++) {
        int width = Scale(Context.textExtent(toPrint[i]).x);
        Context.drawText(toPrint[i], (int) ((X - (width / 2)) * m_ZoomFactor), (int) ((Y + yOffset) * m_ZoomFactor), true);
        yOffset = yOffset + Scale(Context.textExtent(toPrint[i]).y);
      }
    } else if (Justified_to == Justification_c.Center) {
      // Start by Centering the text block in the y axis
      yOffset = -Scale(Context.textExtent(Text).y) / 2;
      for (int i = 0; i < toPrint.length; i++) {
        int width = Scale(Context.textExtent(toPrint[i]).x);
        Context.drawText(toPrint[i], (int) ((X - (width / 2)) * m_ZoomFactor), (int) ((Y + yOffset) * m_ZoomFactor), true);
        yOffset = yOffset + Scale(Context.textExtent(toPrint[i]).y);
      }
    } else if (Justified_to == Justification_c.Right) {
      for (int i = 0; i < toPrint.length; i++) {
        int width = Scale(Context.textExtent(toPrint[i]).x);
        Context.drawText(toPrint[i], (int) ((X - width) * m_ZoomFactor), (int) ((Y + yOffset) * m_ZoomFactor), true);
        yOffset = yOffset + Scale(Context.textExtent(toPrint[i]).y);
      }
    } else {
      Context.drawText(Text, (int) (X * m_ZoomFactor), (int) (Y * m_ZoomFactor), true);
    }
  } // End drawText
  public static void Drawrect(final GCDelegate Context, boolean filled, final int H, final int W, final int X, final int Y) {
    if (filled) {
    	Context.fillRectangle((int) (X * m_ZoomFactor), (int) (Y * m_ZoomFactor), (int) (W * m_ZoomFactor), (int) (H * m_ZoomFactor));
    }
    Context.drawRectangle((int) (X * m_ZoomFactor), (int) (Y * m_ZoomFactor), (int) (W * m_ZoomFactor), (int) (H * m_ZoomFactor));
  } // End drawRect
  public static void Clipto(final GCDelegate Context, final int H, final int W, final int X, final int Y) {
    Context.setClipping((int) (X * m_ZoomFactor), (int) (Y * m_ZoomFactor), (int) (W * m_ZoomFactor), (int) (H * m_ZoomFactor));
  } // End clipTo
  public static int Gettextextent(final int Axis, final GCDelegate Context, final String Text) {
  	if ( Context == null )
  	{   
		return 0;
  	} 
    Point extent = Context.textExtent(Text);
    if (Axis == Axis_c.X)
      return Scale(extent.x);
    else
      return Scale(extent.y);
{'fraction_non_alphanumeric': 0.16660384470410855, 'fraction_numerical': 0.008386732001507727, 'mean_word_length': 3.5257995735607675, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '14988', 'n_tokens_mistral': 3486, 'n_tokens_neox': 3353, 'n_words': 981}