Class Constants


  • public class Constants
    extends java.lang.Object
    The Constants class is a holding area for any "global" variables that are needed for multiple classes. Also included are several utility methods that may be used any place that needs them. It is hoped that there will be no hard-coded values anywhere.

    Modified by: Joseph A. Huwaldt

    Version:
    February 22, 2025
    Author:
    JDN, Version 1.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static boolean DEBUG
      Sets debug mode.
      static char Delim
      Globalized delimiter character.
      static double Grain
      Globalized grain value.
      static java.awt.Color[] IGESColor
      Standard IGES Colors (Index 0, "undefined" is set to black).
      static int PDID_COL
      Column in IGES file Parameter Data delimiting free-form data with DENum of the entity.
      static java.util.ResourceBundle RESOURCES
      The String resources used by this package.
      static int SECTID_COL
      Column in IGES file with section identifier ('S', 'G', etc)
      static char Term
      Globalized terminate character.
      static int TYPE_CHAR
      Character type identifier.
      static int TYPE_FLOAT
      Real type identifier.
      static int TYPE_INT
      Integer type identifier.
      static int TYPE_STRING
      String type identifier.
      static javax.measure.unit.Unit<javax.measure.quantity.Length> unit
      Globalized length units for the file.
      static java.util.Locale US
      The IGES ASCII file format must always be written using the US locale.
      static int X_AXIS
      X-Axis
      static int Y_AXIS
      Y-Axis
      static int Z_AXIS
      Z-Axis
    • Constructor Summary

      Constructors 
      Constructor Description
      Constants()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double dist​(double x1, double y1, double x2, double y2)
      2D distance.
      static double dist​(double x1, double y1, double z1, double x2, double y2, double z2)
      3D distance.
      static void initGlobals​(GlobalSection g)
      Set up globals from GlobalSection
      static java.lang.String makeSequenceNumber​(int number)
      Create a sequence number using the specified integer and padding it with zeros on the left until it is 7 characters long.
      static java.lang.String myReadLine​(java.io.RandomAccessFile in)
      Reads in a line of text, 80 characters, ignoring any EOL chars
      static java.lang.String padLeft​(java.lang.String string, char pad, int length)
      Add the specified pad character to the left of the input String until it is the specified length.
      static java.lang.String padRight​(java.lang.String string, char pad, int length)
      Add the specified pad character to the right of the input String until it is the specified length.
      static double toDouble​(java.lang.String s)
      Converts the string to an double.
      static int toInt​(java.lang.String s)
      Converts the string to an integer.
      static int writeSection​(java.io.PrintWriter writer, int startIndex, java.lang.String deNumber, char sectionCode, java.lang.StringBuilder data)
      Write out a single section of an IGES file.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • RESOURCES

        public static final java.util.ResourceBundle RESOURCES
        The String resources used by this package.
      • US

        public static final java.util.Locale US
        The IGES ASCII file format must always be written using the US locale.
      • PDID_COL

        public static final int PDID_COL
        Column in IGES file Parameter Data delimiting free-form data with DENum of the entity. According to the IGES specification, this must be a space (' ').
        See Also:
        Constant Field Values
      • Term

        public static char Term
        Globalized terminate character. Done this way because Part.getGlobal().getTerm() was too long to type over and over.
      • Delim

        public static char Delim
        Globalized delimiter character. Done this way because Part.getGlobal().getDelim() was too long to type over and over.
      • Grain

        public static double Grain
        Globalized grain value. Done this way because Part.getGlobal().getGrain() was too long to type over and over.
      • unit

        public static javax.measure.unit.Unit<javax.measure.quantity.Length> unit
        Globalized length units for the file. Done this way because Part.getGlobal().getUnit() was too long to type over and over.
      • IGESColor

        public static final java.awt.Color[] IGESColor
        Standard IGES Colors (Index 0, "undefined" is set to black).
    • Method Detail

      • initGlobals

        public static void initGlobals​(GlobalSection g)
        Set up globals from GlobalSection
        Parameters:
        g - Global Section object
      • myReadLine

        public static java.lang.String myReadLine​(java.io.RandomAccessFile in)
                                           throws java.io.IOException
        Reads in a line of text, 80 characters, ignoring any EOL chars
        Parameters:
        in - input file
        Returns:
        the single text line of input
        Throws:
        java.io.IOException - if end of file is reached, or other generic file I/O error.
      • toInt

        public static int toInt​(java.lang.String s)
        Converts the string to an integer. This method can handle "integers" that are technically real, such as 1.000D+001. A zero length string results in the value 0 being returned.
        Parameters:
        s - the string to be parsed. Assumed to be trimmed of whitespace.
        Returns:
        resulting integer
      • toDouble

        public static double toDouble​(java.lang.String s)
        Converts the string to an double. This method can handle IGES floats of single ("1.00e+010") or double ("1.00d+010") precision. A zero length string results in the value 0.0 being returned.
        Parameters:
        s - the string to be parsed. Assumed to be trimmed of whitespace.
        Returns:
        resulting double value
      • dist

        public static double dist​(double x1,
                                  double y1,
                                  double x2,
                                  double y2)
        2D distance. Distance between two points in a plane.
        Parameters:
        x1 - abscissa of first point
        y1 - ordinate of first point
        x2 - abscissa of 2nd point
        y2 - ordinate of second point
        Returns:
        2D distance between the points
      • dist

        public static double dist​(double x1,
                                  double y1,
                                  double z1,
                                  double x2,
                                  double y2,
                                  double z2)
        3D distance. Distance between two points in space.
        Parameters:
        x1 - X-coordinate of
        y1 - Y-coordinate of
        z1 - Z-coordinate of first point
        x2 - X-coordinate of second point
        y2 - Y-coordinate of second point
        z2 - Z-coordinate of second point
        Returns:
        3D distance between the points
      • padLeft

        public static java.lang.String padLeft​(java.lang.String string,
                                               char pad,
                                               int length)
        Add the specified pad character to the left of the input String until it is the specified length.
        Parameters:
        string - The string to be made the specified length.
        pad - The character to insert into the beginning of the string to reach the specified length.
        length - The desired length of the padded string.
        Returns:
        The input string padded with the specified pad character on the left until the length matches the specified length.
      • padRight

        public static java.lang.String padRight​(java.lang.String string,
                                                char pad,
                                                int length)
        Add the specified pad character to the right of the input String until it is the specified length.
        Parameters:
        string - The string to be made the specified length.
        pad - The character to append onto the string to reach the specified length.
        length - The desired length of the padded string.
        Returns:
        The input string padded with the specified pad character on the right until the length matches the specified length.
      • makeSequenceNumber

        public static java.lang.String makeSequenceNumber​(int number)
        Create a sequence number using the specified integer and padding it with zeros on the left until it is 7 characters long.
        Parameters:
        number - The number to turn into a sequence number.
        Returns:
        A properly formatted sequence number made from the input integer.
      • writeSection

        public static int writeSection​(java.io.PrintWriter writer,
                                       int startIndex,
                                       java.lang.String deNumber,
                                       char sectionCode,
                                       java.lang.StringBuilder data)
                                throws java.io.IOException
        Write out a single section of an IGES file. The section is provided as a single String that contains no line-breaks or control characters. The output will be limited to 72 characters plus a section code and sequence index.
        Parameters:
        writer - The PrintWriter to write the section to.
        startIndex - The starting sequence index for this section.
        deNumber - The 7 character DE number code (made with "makeSequenceNumber") for this part or "".
        sectionCode - The code used to identify this section's type ('S', 'G', 'P', etc").
        data - A String containing the data for the section.
        Returns:
        The index for the next sequence following this section.
        Throws:
        java.io.IOException - if the section could not be written.