//
// LabelJ3D.java
//

/*
VisAD system for interactive analysis and visualization of numerical
data.  Copyright (C) 1996 - 2017 Bill Hibbard, Curtis Rueden, Tom
Rink, Dave Glowacki, Steve Emmerson, Tom Whittaker, Don Murray, and
Tommy Jasmin.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA
*/

package visad.bom.annotations;

import visad.TextControl;
import visad.VisADException;

import visad.DisplayImpl;
import visad.java3d.DisplayImplJ3D;

import visad.util.HersheyFont;

import java.awt.Font;

/**
 *  Meant to encapsulate information representing a label which is
 *  going to be rendered on a VisAD display without being
 *  subject to the usual VisAD transformations. Thus the label should
 *  stick in Screen Coordinates. Uses VisAD fonts.
 *
 *  Java3D dependent only in needing Shape3D.
 */
public class LabelJ3D implements ScreenAnnotation
{
  private String text;
  private int xLocation;      // screen coordinates
  private int yLocation;      // screen coordinates
  private float[] colour;
  // Only one of these may be non null
  private Font font;           // null for the default
  private HersheyFont hfont;   // null for the default
  private TextControl.Justification horizontalJustification;
  private TextControl.Justification verticalJustification;
  private double fontSizeInPixels;
  private double zValue;
  private boolean filled;
  private double thickness;
  private double orientation;  // anticlockwise from x-axis in degrees.
  private double charRotation;

  /**
   *  It constructs a LabelJ3D with the given text at the
   *  origin, coloured white, left justified, horizontally aligned
   *  with no character rotation.
   *
   *  @param text  text of the LabelJ3D.
   */
  public LabelJ3D(String text)
        {
    this(text, 0, 0, new float[] {1, 1, 1},
      null, null, 0.0, 12.0, true, 1.0, 0.0,
      TextControl.Justification.LEFT,
      TextControl.Justification.BOTTOM, 0.0);
  }

  /**
   *  It constructs a LabelJ3D with the given text at the
   *  specified location, coloured white, left justified,
   *  horizontally aligned with no character rotation.
   *
   *  @param text  text of the LabelJ3D.
   *  @param xLocation  x position in screen coordinates.
   *  @param yLocation  y position in screen coordinates.
   */
  public LabelJ3D(String text, int xLocation, int yLocation)
        {
    this(text, xLocation, yLocation, new float[] {1, 1, 1},
      null, null, 0.0, 12.0, true, 1.0, 0.0,
      TextControl.Justification.LEFT,
      TextControl.Justification.BOTTOM,
      0.0);
  }

  /**
   *  Constructor for a filled font. It uses the java.awt.Font if it
   *  is not null, otherwise it will use the Hershey font. If both are
   *  null it will use the VisAD line font.
   *
   *  @param text  text of the LabelJ3D.
   *  @param xLocation  x position in screen coordinates.
   *  @param yLocation  y position in screen coordinates.
   *  @param colour  red green blue triple; each value in [0.0, 1.0].
   *  @param font  {@link java.awt.Font} to use.
   *  @param hfont  Hershey font to use; if both fonts are null
   *         then use the default VisAD line font.
   *  @param zValue  Virtual world value; larger z is in front.
   *  @param fontSizeInPixels  font size; by default characters
   *         are 12 pixels in size.
   *  @param horizontalJustification  one of 
   *  @param verticalJustification  one of 
   */
  public LabelJ3D(String text, int xLocation,
    int yLocation, float[] colour, Font font, HersheyFont hfont,
    double zValue, double fontSizeInPixels,
    TextControl.Justification horizontalJustification,
    TextControl.Justification verticalJustification)
  {
    this(text, xLocation, yLocation, colour, font, hfont,
      zValue, fontSizeInPixels, true, 1.0, 0.0,
      horizontalJustification, verticalJustification,
      0.0);
  }

  /**
   *  Constructor for a filled or unfilled font. It uses the java.awt.Font
   *  if it is not null otherwise it will use the Hershey font. If both
   *  are null it will use the VisAD line font.
   *
   *  @param text  text of the LabelJ3D.
   *  @param xLocation  x position in screen coordinates.
   *  @param yLocation  y position in screen coordinates.
   *  @param colour  red green blue triple; each value in [0.0, 1.0].
   *  @param font  java.awt.Font to use.
   *  @param hfont  Hershey font to use; if both fonts are null
   *         then use the default VisAD line font.
   *  @param zValue  Virtual world value; larger z is in front.
   *  @param fontSizeInPixels  font size; by default characters
   *         are 12 pixels in size.
   *  @param filled  if true the font is rendered as filled,
   *         if false just the triangles are drawn.
   *  @param thickness  line width to use if just drawing triangles;
   *          usually 1.0 is the most useful.
   *  @param horizontalJustification  one of 
   *  @param verticalJustification  one of 
   */
  public LabelJ3D(String text, int xLocation,
    int yLocation, float[] colour, Font font, HersheyFont hfont,
    double zValue, double fontSizeInPixels, boolean filled,
    double thickness,
    TextControl.Justification horizontalJustification,
    TextControl.Justification verticalJustification)
  {
    this(text, xLocation, yLocation, colour, font, hfont,
      zValue, fontSizeInPixels, filled, thickness, 0.0,
      horizontalJustification, verticalJustification,
      0.0);
  }

  /**
   *  Constructor for LabelJ3D. It uses the {@link java.awt.Font} if it
   *  is not null, otherwise it will use the Hershey font. If both are
   *  null it will use the VisAD line font.
   *
   *  @param text  text of the LabelJ3D.
   *  @param xLocation  x position in screen coordinates.
   *  @param yLocation  y position in screen coordinates.
   *  @param colour  red green blue triple; each value in [0.0, 1.0].
   *  @param font  {@link java.awt.Font} to use.
   *  @param hfont  Hershey font to use; if both fonts are null
   *         then use the default VisAD line font.
   *  @param zValue  Virtual world value; larger z is in front.
   *  @param fontSizeInPixels  font size; by default characters
   *         are 12 pixels in size.
   *  @param filled  if true the font is rendered as filled,
   *         if false just the triangles are drawn.
   *  @param thickness  line width to use if just drawing triangles;
   *          usually 1.0 is the most useful.
   *  @param orientation  anticlockwise from x-axis in degrees.
   *  @param horizontalJustification  one of 

Ads help maintain this website.