<commit_before>/**
 * Copyright 2010 The PlayN Authors
 *
 * 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.
 */
package playn.core;

/**
 * Contains configuration for laying out and drawing single- or multi-line text to a {@link
 * Canvas}.
 */
public class TextFormat {

  /** Used to align multiline text. */
  public static enum Alignment {
    LEFT {
      @Override
      public float getX(float textWidth, float lineWidth) {
        return 0;
      }
    },
    CENTER {
      @Override
      public float getX(float textWidth, float lineWidth) {
        return (lineWidth - textWidth)/2;
      }
    },
    RIGHT {
      @Override
      public float getX(float textWidth, float lineWidth) {
        return (lineWidth - textWidth);
      }
    };

    /** Returns the x offset for text with the specified width rendered on a line of the specified
     * width. */
    public abstract float getX(float textWidth, float lineWidth);
  };

  /** @deprecated Use stroke and fill to create your own effects. */
  @Deprecated
  public static abstract class Effect {
    /** @deprecated Use stroke and fill to create your own effects. */
    @Deprecated
    public static final Effect NONE = new Effect() {
      @Override
      public String toString() {
        return "none";
      }
    };

    /** @deprecated Use stroke and fill to create your own effects. */
    @Deprecated
    public static Effect shadow (int shadowColor, float shadowOffsetX, float shadowOffsetY) {
      return new Shadow(shadowColor, shadowOffsetX, shadowOffsetY);
    }

    /** @deprecated Use stroke and fill to create your own effects. */
    @Deprecated
    public static Effect outline (int outlineColor) {
      return new PixelOutline(outlineColor);
    }

    /** @deprecated Use stroke and fill to create your own effects. */
    @Deprecated
    public static final class Shadow extends Effect {
      /** The color of the shadow (as {@code 0xAARRGGBB}). */
      public final int shadowColor;

      /** The pixel offset of the shadow in the x-direction. */
      public final float shadowOffsetX;

      /** The pixel offset of the shadow in the y-direction. */
      public final float shadowOffsetY;

      public Shadow (int shadowColor, float shadowOffsetX, float shadowOffsetY) {
        this.shadowColor = shadowColor;
        this.shadowOffsetX = shadowOffsetX;
        this.shadowOffsetY = shadowOffsetY;
      }

      @Override
      public float adjustWidth (float width) {
        return width + Math.abs(shadowOffsetX);
      }

      @Override
      public float adjustHeight (float height) {
        return height + Math.abs(shadowOffsetY);
      }

      @Override
      public Integer getAltColor () {
        return shadowColor;
      }

      @Override
      public String toString() {
        return "shadow [color=" + Integer.toHexString(shadowColor) +
          ", offX=" + shadowOffsetX + ", offY=" + shadowOffsetY + "]";
      }
    }

    /** @deprecated Use stroke and fill to create your own effects. */
    @Deprecated
    public static final class PixelOutline extends Effect {
      /** The color of the outline (as {@code 0xAARRGGBB}). */
      public final int outlineColor;

      public PixelOutline (int outlineColor) {
        this.outlineColor = outlineColor;
      }

      @Override
      public float adjustWidth (float width) {
        return width + 2;
      }
      @Override
      public float adjustHeight (float height) {
        return height + 2;
      }
      @Override
      public Integer getAltColor () {
        return outlineColor;
      }

      @Override
      public String toString() {
        return "poutline [color=" + Integer.toHexString(outlineColor) + "]";
      }
    }

    /** Used internally for text layout calculations. */
    public float adjustWidth (float width) {
      return width;
    }

    /** Used internally for text layout calculations. */
    public float adjustHeight (float height) {
      return height;
    }

    /** Used internally for text rendering. */
    public Integer getAltColor () {
      return null;
    }

    private Effect () {} // disallow other classes to extend this one
  }

  /** The font in which to render the text (or null which indicates that the default font should be
   * used). */
  public final Font font;

  /** The width at which to wrap lines of text (or {@link Float#MAX_VALUE} if the text should not
   * be wrapped. */
  public final float wrapWidth;

  /** The alignment to use for multiline text. */
  public final Alignment align;

  /** @deprecated Use set the stroke or fill color on the canvas instead. */
  @Deprecated
  public final int textColor;

  /** @deprecated Use stroke and fill to create your own effects. */
  @Deprecated
  public final Effect effect;

  /** Creates a default text format instance. */
  public TextFormat() {
    this(null, Float.MAX_VALUE, Alignment.LEFT, 0xFF000000, Effect.NONE);
  }

  /** Creates a configured text format instance. */
  public TextFormat(Font font, float wrapWidth, Alignment align, int textColor, Effect effect) {
    this.font = font;
    this.wrapWidth = wrapWidth;
    this.align = align;
    this.textColor = textColor;
    this.effect = effect;
  }

  /** Returns true if line wrapping is desired. */<commit_msg>Added a TextFormat ctor that doesn't take the deprecated info.<commit_after>/**
 * Copyright 2010 The PlayN Authors
 *
 * 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.
 */
package playn.core;

/**
 * Contains configuration for laying out and drawing single- or multi-line text to a {@link
 * Canvas}.
 */
public class TextFormat {

  /** Used to align multiline text. */
  public static enum Alignment {
    LEFT {
      @Override
      public float getX(float textWidth, float lineWidth) {
        return 0;
      }
    },
    CENTER {
      @Override
      public float getX(float textWidth, float lineWidth) {
        return (lineWidth - textWidth)/2;
      }
    },
    RIGHT {
      @Override
      public float getX(float textWidth, float lineWidth) {
        return (lineWidth - textWidth);
      }
    };

    /** Returns the x offset for text with the specified width rendered on a line of the specified
     * width. */
    public abstract float getX(float textWidth, float lineWidth);
  };

  /** @deprecated Use stroke and fill to create your own effects. */
  @Deprecated
  public static abstract class Effect {
    /** @deprecated Use stroke and fill to create your own effects. */
    @Deprecated
    public static final Effect NONE = new Effect() {
      @Override
      public String toString() {
        return "none";
      }
    };

    /** @deprecated Use stroke and fill to create your own effects. */
    @Deprecated
    public static Effect shadow (int shadowColor, float shadowOffsetX, float shadowOffsetY) {
      return new Shadow(shadowColor, shadowOffsetX, shadowOffsetY);
    }

    /** @deprecated Use stroke and fill to create your own effects. */
    @Deprecated
    public static Effect outline (int outlineColor) {
      return new PixelOutline(outlineColor);
    }

    /** @deprecated Use stroke and fill to create your own effects. */
    @Deprecated
    public static final class Shadow extends Effect {
      /** The color of the shadow (as {@code 0xAARRGGBB}). */
      public final int shadowColor;

      /** The pixel offset of the shadow in the x-direction. */
      public final float shadowOffsetX;

      /** The pixel offset of the shadow in the y-direction. */
      public final float shadowOffsetY;

      public Shadow (int shadowColor, float shadowOffsetX, float shadowOffsetY) {
        this.shadowColor = shadowColor;
        this.shadowOffsetX = shadowOffsetX;
        this.shadowOffsetY = shadowOffsetY;
      }

      @Override
      public float adjustWidth (float width) {
        return width + Math.abs(shadowOffsetX);
      }

      @Override
      public float adjustHeight (float height) {
        return height + Math.abs(shadowOffsetY);
      }

      @Override
      public Integer getAltColor () {
        return shadowColor;
      }

      @Override
      public String toString() {
        return "shadow [color=" + Integer.toHexString(shadowColor) +
          ", offX=" + shadowOffsetX + ", offY=" + shadowOffsetY + "]";
      }
    }

    /** @deprecated Use stroke and fill to create your own effects. */
    @Deprecated
    public static final class PixelOutline extends Effect {
      /** The color of the outline (as {@code 0xAARRGGBB}). */
      public final int outlineColor;

      public PixelOutline (int outlineColor) {
        this.outlineColor = outlineColor;
      }

      @Override
      public float adjustWidth (float width) {
        return width + 2;
      }
      @Override
      public float adjustHeight (float height) {
        return height + 2;
      }
      @Override
      public Integer getAltColor () {
        return outlineColor;
      }

      @Override
      public String toString() {
        return "poutline [color=" + Integer.toHexString(outlineColor) + "]";
      }
    }

    /** Used internally for text layout calculations. */
    public float adjustWidth (float width) {
      return width;
    }

    /** Used internally for text layout calculations. */
    public float adjustHeight (float height) {
      return height;
    }

    /** Used internally for text rendering. */
    public Integer getAltColor () {
      return null;
    }

    private Effect () {} // disallow other classes to extend this one
  }

  /** The font in which to render the text (or null which indicates that the default font should be
   * used). */
  public final Font font;

  /** The width at which to wrap lines of text (or {@link Float#MAX_VALUE} if the text should not
   * be wrapped. */
  public final float wrapWidth;

  /** The alignment to use for multiline text. */
  public final Alignment align;

  /** @deprecated Use set the stroke or fill color on the canvas instead. */
  @Deprecated
  public final int textColor;

  /** @deprecated Use stroke and fill to create your own effects. */
  @Deprecated
  public final Effect effect;

  /** Creates a default text format instance. */
  public TextFormat() {
    this(null, Float.MAX_VALUE, Alignment.LEFT, 0xFF000000, Effect.NONE);
  }

  /** @deprecated Use stroke and fill to create your own effects. */
  @Deprecated
  public TextFormat(Font font, float wrapWidth, Alignment align, int textColor, Effect effect) {
    this.font = font;
    this.wrapWidth = wrapWidth;
    this.align = align;
    this.textColor = textColor;
    this.effect = effect;
  }

  /** Creates a configured text format instance. */
  public TextFormat(Font font, float wrapWidth, Alignment align) {
    this.font = font;
    this.wrapWidth = wrapWidth;
    this.align = align;
    this.textColor = 0xFF000000;
    this.effect = Effect.NONE;
  }

  /** Returns true if line wrapping is desired. */
{'fraction_non_alphanumeric': 0.08691275167785235, 'fraction_numerical': 0.004110738255033557, 'mean_word_length': 2.5755848830233954, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5918557', 'n_tokens_mistral': 3193, 'n_tokens_neox': 3073, 'n_words': 1259}