<commit_before>package info.limpet.stackedcharts.ui.editor.figures;

import info.limpet.stackedcharts.ui.editor.Activator;

import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.ImageUtilities;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.swt.graphics.Image;

/**
 * The label is a standard horizontal label by default and it can change orientation to vertical
 * 
 */
public class DirectionalLabel extends Label
{

  private boolean vertical;

  public DirectionalLabel(String fontName)
  {
    setFont(Activator.getDefault().getFont(fontName));
  }

  @Override
  protected void paintFigure(Graphics graphics)
  {
    if (vertical)
    {

      String subStringText = getSubStringText();
      if (!subStringText.isEmpty())
      {
        Image image =
            ImageUtilities.createRotatedImageOfString(subStringText, getFont(),
                getForegroundColor(), getBackgroundColor());
        graphics.drawImage(image, new Point(getTextLocation())
            .translate(getLocation()));
        image.dispose();
      }
    }
    else
    {
      super.paintFigure(graphics);
    }
  }

  @Override
  protected Dimension calculateLabelSize(Dimension txtSize)
  {
    Dimension labelSize = super.calculateLabelSize(txtSize);
    if (vertical)
    {
      labelSize = labelSize.transpose();
    }
    return labelSize;
  }

  public void setVertical(boolean vertical)
  {
    this.vertical = vertical;
    repaint();
  }

}
<commit_msg>fix Shared Axis label issue #294<commit_after>package info.limpet.stackedcharts.ui.editor.figures;

import info.limpet.stackedcharts.ui.editor.Activator;

import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.ImageUtilities;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.swt.graphics.Image;

/**
 * The label is a standard horizontal label by default and it can change orientation to vertical
 * 
 */
public class DirectionalLabel extends Label
{

  private boolean vertical;

  public DirectionalLabel(String fontName)
  {
    setFont(Activator.getDefault().getFont(fontName));
  }

  @Override
  protected void paintFigure(Graphics graphics)
  {
    if (vertical)
    {

      String subStringText = getSubStringText();
      if (!subStringText.isEmpty())
      {
        Image image =
            ImageUtilities.createRotatedImageOfString(subStringText, getFont(),
                getForegroundColor(), getBackgroundColor());
        graphics.drawImage(image, new Point(getTextLocation())
            .translate(getLocation()));
        image.dispose();
      }
    }
    else
    {
      super.paintFigure(graphics);
    }
  }

  @Override
  protected Dimension calculateLabelSize(Dimension txtSize)
  {
    Dimension labelSize = super.calculateLabelSize(txtSize);
    if (vertical)
    {
      labelSize = labelSize.transpose();
    }
    return labelSize;
  }

  public void setVertical(boolean vertical)
  {
    this.vertical = vertical;
    repaint();
    invalidate();
  }

}

{'fraction_non_alphanumeric': 0.09945808096907874, 'fraction_numerical': 0.004144086707044948, 'mean_word_length': 3.281036834924966, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7326204', 'n_tokens_mistral': 926, 'n_tokens_neox': 906, 'n_words': 186}