Exemple #1
0
/**
 * Placeholder for constants that are accessed from generated code.
 *
 * @author Bowen Alpern
 * @author Mauricio Serrano
 * @author John Whaley
 */
public class VM_Math {

  // -#if RVM_FOR_IA32
  /** A well-known memory location used to manipulate the FPU control word. */
  static int FPUControlWord;
  // -#endif RVM_FOR_IA32

  /*
   * Constants that are used by the compilers in generated code.
   */
  static final double I2Dconstant = Double.longBitsToDouble(0x4330000080000000L);
  static final double IEEEmagic = Double.longBitsToDouble(0x4338000000000000L);
  static final long longOne = 1L;
  static final float minusOne = -1.0F;
  static final float zero = 0.0F;
  static final float half = 0.5F;
  static final float one = 1.0F;
  static final float two = 2.0F;
  static final double zeroD = 0.0;
  static final double oneD = 1.0;
  static final float half32 = java.lang.Float.intBitsToFloat(0x2f800000);
  static final float two32 = java.lang.Float.intBitsToFloat(0x4f800000);
  static final double billionth = 1e-9;

  // largest double that can be rounded to an int
  static final double maxint = 0.5D + 0x7FFFFFFF;

  // smallest double that can be rounded to an int
  static final double minint = (double) Integer.MIN_VALUE;
}
Exemple #2
0
 @Override
 public int hashCode() {
   int result = 11;
   result = 31 * result + (this.isMutable() ? 1 : 0);
   result = 31 * result + java.lang.Float.floatToIntBits(this.x());
   result = 31 * result + java.lang.Float.floatToIntBits(this.y());
   result = 31 * result + java.lang.Float.floatToIntBits(this.z());
   return result;
 }
Exemple #3
0
 /**
  * Constructs a vector using the specified coordinates. There are no restrictions on the values of
  * these points except that none of them can be {@code NaN}.
  *
  * @param mutable whether this vector can be directly modified
  * @param x the x-coordinate of this vector
  * @param y the y-coordinate of this vector
  * @param z the z-coordinate of this vector
  * @throws IllegalArgumentException if any coordinate is {@code NaN}
  */
 private Vector3f(final boolean mutable, final float x, final float y, final float z) {
   super(mutable);
   if (java.lang.Float.isNaN(x)) {
     throw new IllegalArgumentException("x is NaN");
   }
   if (java.lang.Float.isNaN(y)) {
     throw new IllegalArgumentException("y is NaN");
   }
   if (java.lang.Float.isNaN(z)) {
     throw new IllegalArgumentException("z is NaN");
   }
   this.x = x;
   this.y = y;
   this.z = z;
 }
 public GradientOrientation(final Map<String, String> args) {
   if (args.containsKey("start") && args.containsKey("end")) {
     final String startStr = args.get("start");
     final String endStr = args.get("end");
     final float[] pos0 = parsePosition(startStr);
     final float[] pos1 = parsePosition(endStr);
     super.x1 = pos0[0];
     super.y1 = pos0[1];
     super.x2 = pos1[0];
     super.y2 = pos1[1];
     this.type = Type.LINEAR;
   } else if (args.containsKey("center") && args.containsKey("radius")) {
     final String centerStr = args.get("center");
     final float[] pos0 = parsePosition(centerStr);
     super.x1 = pos0[0];
     super.y1 = pos0[1];
     final String radiusStr = args.get("radius");
     try {
       final float radius = java.lang.Float.parseFloat(radiusStr);
       final double angle = Math.atan2(y1, x1);
       super.x2 = super.x1 + (float) (radius * Math.cos(angle));
       super.y2 = super.y1 + (float) (radius * Math.sin(angle));
     } catch (NumberFormatException e) {
       throw new IllegalArgumentException("radius must be a valid float");
     }
     this.type = Type.RADIAL;
   } else {
     throw new IllegalArgumentException("Args do not define a legal gradient orientation");
   }
 }
  /**
   * @param value
   * @param type
   * @return
   */
  private Object createTypedObject(String value, Class type) {
    if (java.lang.String.class == type) return value;
    else if (java.lang.Integer.class == type) return java.lang.Integer.parseInt(value);
    else if (java.lang.Long.class == type) return java.lang.Long.parseLong(value);
    else if (java.lang.Boolean.class == type) return java.lang.Boolean.parseBoolean(value);
    else if (java.lang.Float.class == type) return java.lang.Float.parseFloat(value);
    else if (java.lang.Double.class == type) return java.lang.Double.parseDouble(value);

    return null;
  }
 @java.lang.Override
 @java.lang.SuppressWarnings("all")
 public boolean equals(final java.lang.Object o) {
   if (o == this) return true;
   if (!(o instanceof EqualsAndHashCode2)) return false;
   final EqualsAndHashCode2 other = (EqualsAndHashCode2) o;
   if (this.x != other.x) return false;
   if (this.y != other.y) return false;
   if (java.lang.Float.compare(this.f, other.f) != 0) return false;
   if (java.lang.Double.compare(this.d, other.d) != 0) return false;
   return true;
 }
 @java.lang.Override
 @java.lang.SuppressWarnings("all")
 public int hashCode() {
   final int PRIME = 59;
   int result = 1;
   result = result * PRIME + this.x;
   final long $y = this.y;
   result = result * PRIME + (int) ($y >>> 32 ^ $y);
   result = result * PRIME + java.lang.Float.floatToIntBits(this.f);
   final long $d = java.lang.Double.doubleToLongBits(this.d);
   result = result * PRIME + (int) ($d >>> 32 ^ $d);
   return result;
 }
 private static float[] parsePosition(final String str) {
   final String[] pieces = str.trim().split(",");
   if (pieces.length != 2)
     throw new IllegalArgumentException("Must have only 2 positions: " + str);
   final float[] pos = new float[2];
   for (int i = 0; i < 2; i++) {
     try {
       pos[i] = java.lang.Float.parseFloat(pieces[i].trim());
     } catch (NumberFormatException e) {
       throw new IllegalArgumentException(
           String.format("position '%s' must be a float: %s", pieces[i], str));
     }
   }
   return pos;
 }
 public String toString() {
   return java.lang.Float.toString(elem);
 }
  public void generatePdf(java.lang.String memNo) {

    java.lang.Process wait_for_Pdf2Show;

    java.util.Calendar cal = java.util.Calendar.getInstance();

    java.util.Date dateStampPdf = cal.getTime();

    java.lang.String pdfDateStamp = dateStampPdf.toString();

    try {

      java.io.File tempFile =
          java.io.File.createTempFile("REP" + this.getDateLable() + "_", ".pdf");

      tempFile.deleteOnExit();

      java.lang.Runtime rt = java.lang.Runtime.getRuntime();

      java.lang.String debitTotal = null;

      java.lang.String creditTotal = null;

      com.lowagie.text.Document docPdf =
          new com.lowagie.text.Document(
              new Rectangle(
                  java.lang.Float.parseFloat(System.getProperty("papersize_width")),
                  java.lang.Float.parseFloat(System.getProperty("papersize_legnth"))),
              java.lang.Float.parseFloat(System.getProperty("receiptPageMargin")),
              java.lang.Float.parseFloat(System.getProperty("receiptPageMargin")),
              java.lang.Float.parseFloat(System.getProperty("receiptPageMargin")),
              java.lang.Float.parseFloat(System.getProperty("receiptPageMargin")));

      try {

        try {

          com.lowagie.text.pdf.PdfWriter.getInstance(
              docPdf, new java.io.FileOutputStream(tempFile));

          String compName = null;
          String date = null;
          /* try {


              java.sql.Statement st3 = connectDB.createStatement();
              java.sql.Statement st4 = connectDB.createStatement();

              java.sql.ResultSet rset2 = st3.executeQuery("SELECT hospital_name from pb_hospitalprofile");
              java.sql.ResultSet rset4 = st4.executeQuery("SELECT date('now') as Date");
              while(rset2.next())
                  compName = rset2.getObject(1).toString();

              while(rset4.next())
                  date = rset4.getObject(1).toString();

              com.lowagie.text.HeaderFooter headerFoter = new com.lowagie.text.HeaderFooter(new Phrase(""+compName+"                                                        Printed On: "+date+""),false);// FontFactory.getFont(com.lowagie.text.FontFactory.HELVETICA, 14, Font.BOLDITALIC,java.awt.Color.blue)));

              //  com.lowagie.text.HeaderFooter headerFoter = new com.lowagie.text.HeaderFooter(new Phrase(""+compName+""),false);// FontFactory.getFont(com.lowagie.text.FontFactory.HELVETICA, 14, Font.BOLDITALIC,java.awt.Color.blue)));
              headerFoter.setRight(5);
              docPdf.setHeader(headerFoter);

          } catch(java.sql.SQLException SqlExec) {

              javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), SqlExec.getMessage());

          }
          */
          //   com.lowagie.text.HeaderFooter footer = new com.lowagie.text.HeaderFooter(new
          // Phrase("Member Statements - Page: "), true);//
          // FontFactory.getFont(com.lowagie.text.FontFactory.HELVETICA, 12,
          // Font.BOLDITALIC,java.awt.Color.blue));

          //   docPdf.setFooter(footer);

          docPdf.open();

          try {

            com.lowagie.text.pdf.PdfPTable table = new com.lowagie.text.pdf.PdfPTable(6);
            //   com.lowagie.text.rtf.RtfTable table = new com.lowagie.text.rtf.RtfTable();
            //  Table table = new Table(6);

            int headerwidths[] = {15, 20, 20, 15, 15, 15};

            //  table.setWidths(headerwidths);

            table.setWidthPercentage((100));

            // table.getDefaultCell().setBorder(Rectangle.BOTTOM);

            //  table.getDefaultCell().setColspan(6);

            Phrase phrase = new Phrase("");

            // table.addCell(phrase);
            table.getDefaultCell().setBorderColor(java.awt.Color.WHITE);
            table.getDefaultCell().setColspan(1);
            table.getDefaultCell().setBackgroundColor(java.awt.Color.WHITE);
            table.getDefaultCell().setBorderColor(java.awt.Color.WHITE);

            try {

              java.sql.Statement st = connectDB.createStatement();
              java.sql.Statement st1 = connectDB.createStatement();
              java.sql.Statement st2 = connectDB.createStatement();
              java.sql.Statement st5 = connectDB.createStatement();
              java.sql.Statement st6 = connectDB.createStatement();

              java.sql.Statement st3 = connectDB.createStatement();
              java.sql.ResultSet rset3 =
                  st3.executeQuery(
                      "select hospital_name,postal_code||' '||box_no||' '||town,main_telno||' '||other_telno,initcap(street),main_faxno,email,website,room_no from pb_hospitalprofile");
              //       java.sql.ResultSet rset1 = st1.executeQuery("select
              // cb.dealer,cb.receipt_no,CURRENT_TIMESTAMP(0),cb.patient_no from ac_cash_collection
              // cb, hp_patient_card pc where cb.patient_no = '"+MNo+"' AND cb.date::date =
              // current_date AND cb.transaction_type = 'Receipts' AND pc.paid = false");

              java.sql.ResultSet rset1 = st1.executeQuery("select CURRENT_TIMESTAMP(0)");
              //     java.sql.ResultSet rsetTotals = st2.executeQuery("select sum(pc.credit) as
              // debit from hp_patient_card pc where pc.patient_no = '"+MNo+"' AND
              // pc.transaction_type = 'Receipts' AND pc.paid = false  AND pc.date::date =
              // current_date");
              //  java.sql.ResultSet rs = st.executeQuery("select cb.receipt_no from
              // ac_cash_collection cb, hp_patient_card pc where cb.patient_no = '"+MNo+"' AND
              // pc.paid = false  AND pc.date::date = current_date");
              java.sql.ResultSet rset5 =
                  st5.executeQuery(
                      "select description,sum(quantity),sum(debit) from ac_cash_collection where patient_no = '"
                          + MNo
                          + "' AND date::date = current_date and receipt_no = '"
                          + Receipt
                          + "' group by description");
              java.sql.ResultSet rset6 =
                  st6.executeQuery(
                      "select distinct user_name,cash_point from ac_cash_collection where patient_no = '"
                          + MNo
                          + "' AND date = current_date");
              System.out.println(MNo);

              while (rset3.next()) {
                table.getDefaultCell().setColspan(6);

                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
                phrase = new Phrase(rset3.getObject(1).toString(), pFontHeader1);
                table.addCell(phrase);

                table.getDefaultCell().setColspan(6);
                table.getDefaultCell().setBorderColor(java.awt.Color.white);

                table.getDefaultCell().setColspan(2);

                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
                phrase = new Phrase("Address:" + "\t" + rset3.getObject(2).toString(), pFontHeader);
                table.addCell(phrase);

                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
                phrase = new Phrase("Tel:  " + rset3.getObject(3).toString(), pFontHeader);

                table.addCell(phrase);

                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
                phrase = new Phrase("Fax:  " + rset3.getObject(5).toString(), pFontHeader);

                table.addCell(phrase);
                table.getDefaultCell().setBorderColor(java.awt.Color.white);
                table.getDefaultCell().setColspan(3);
                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
                phrase = new Phrase("Email: " + rset3.getObject(6).toString(), pFontHeader);
                table.addCell(phrase);

                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
                phrase = new Phrase("Website: " + rset3.getObject(7).toString(), pFontHeader);

                table.addCell(phrase);
                /// table.addCell("  ");

              }
              //  table.getDefaultCell().setBorderColor(java.awt.Color.BLACK);
              //  table.getDefaultCell().setBorderWidth(Rectangle.TOP);
              while (rset1.next()) table.getDefaultCell().setColspan(2);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
              //  phrase = new Phrase("Receipt No. "+ rset1.getString(2), pFontHeader);

              phrase = new Phrase("Receipt No. " + Receipt, pFontHeader);

              table.addCell(phrase);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              table.getDefaultCell().setColspan(4);
              phrase = new Phrase("RECEIPT ", pFontHeader1);

              table.addCell(phrase);
              table.getDefaultCell().setColspan(2);

              table.getDefaultCell().setBorderColor(java.awt.Color.WHITE);

              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);

              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
              // phrase = new Phrase("Patient No. "+ rset1.getObject(4).toString(), pFontHeader);
              phrase = new Phrase("Patient No. " + MNo, pFontHeader);

              table.addCell(phrase);
              //  phrase = new Phrase("Name "+ rset1.getObject(1).toString(), pFontHeader);
              phrase = new Phrase("Name " + Name, pFontHeader);

              table.addCell(phrase);

              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
              phrase = new Phrase("Date " + rset1.getObject(1).toString(), pFontHeader);

              table.addCell(phrase);

              table.getDefaultCell().setColspan(3);

              phrase = new Phrase("Description", pFontHeader);
              table.addCell(phrase);
              table.getDefaultCell().setColspan(1);
              phrase = new Phrase("Qty", pFontHeader);
              table.addCell(phrase);
              //  table.addCell("Description");

              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
              table.getDefaultCell().setColspan(2);
              phrase = new Phrase("Amount KShs.", pFontHeader);
              table.addCell(phrase);

              while (rset5.next()) {

                table.getDefaultCell().setColspan(3);

                table.getDefaultCell().setBorderColor(java.awt.Color.WHITE);

                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
                phrase = new Phrase(rset5.getObject(1).toString(), pFontHeader);

                table.addCell(phrase);
                table.getDefaultCell().setColspan(1);
                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
                phrase = new Phrase(rset5.getObject(2).toString(), pFontHeader);

                table.addCell(phrase);

                table.getDefaultCell().setColspan(2);
                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);

                phrase =
                    new Phrase(
                        new com.afrisoftech.sys.Format2Currency()
                            .Format2Currency(rset5.getString(3)),
                        pFontHeader);
                table.addCell(phrase);
              }
              /*              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT);

                           phrase = new Phrase(new com.afrisoftech.sys.Format2Currency().Format2Currency(rset1.getString(5)),pFontHeader);

                           table.addCell(phrase);

                           table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT);

                           phrase = new Phrase(new com.afrisoftech.sys.Format2Currency().Format2Currency(rset1.getString(6)),pFontHeader);

                           table.addCell(phrase);

                       }
              */
              // table.getDefaultCell().setBorderColor(java.awt.Color.BLACK);

              // table.getDefaultCell().setBorder(Rectangle.BOTTOM | Rectangle.TOP);

              //     while (rsetTotals.next()) {

              table.getDefaultCell().setColspan(4);

              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
              phrase = new Phrase("Total", pFontHeader);

              table.addCell(phrase);

              table.getDefaultCell().setColspan(2);

              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);

              // phrase = new Phrase(new
              // com.afrisoftech.sys.Format2Currency().Format2Currency(rsetTotals.getString(1)),pFontHeader);

              phrase =
                  new Phrase(
                      new com.afrisoftech.sys.Format2Currency().Format2Currency(Amount),
                      pFontHeader);

              table.addCell(phrase);

              /*   table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT);
                phrase = new Phrase(new com.afrisoftech.sys.Format2Currency().Format2Currency(rsetTotals.getString(2)),pFontHeader);

                //phrase = new Phrase(" ");

                table.addCell(phrase);

                table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT);

                phrase = new Phrase(new com.afrisoftech.sys.Format2Currency().Format2Currency(rsetTotals.getString(3)),pFontHeader);

                table.addCell(phrase);


              */
              //    }

              while (rset6.next()) table.getDefaultCell().setColspan(3);

              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
              phrase = new Phrase("Payment Mode : " + Paymode, pFontHeader);

              table.addCell(phrase);

              table.getDefaultCell().setColspan(3);

              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
              phrase = new Phrase("Served By : " + rset6.getString(1), pFontHeader);
              table.addCell(phrase);
              table.getDefaultCell().setColspan(3);
              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
              phrase = new Phrase("Cash Point : " + rset6.getString(2).toString(), pFontHeader);
              table.addCell(phrase);

              table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
              table.getDefaultCell().setColspan(3);
              phrase = new Phrase("Thank You. We wish You quick recovery", pFontHeader);
              table.addCell(phrase);

              docPdf.add(table);
              //  java.sql.PreparedStatement pstmt4 = connectDB.prepareStatement("UPDATE
              // hp_patient_card SET paid ='true' WHERE patient_no = '"+MNo+"' AND date::date =
              // current_date");
              //  pstmt4.executeUpdate();
            } catch (java.sql.SQLException SqlExec) {

              javax.swing.JOptionPane.showMessageDialog(
                  new javax.swing.JFrame(), SqlExec.getMessage());
            }

            // }

          } catch (com.lowagie.text.BadElementException BadElExec) {

            javax.swing.JOptionPane.showMessageDialog(
                new javax.swing.JFrame(), BadElExec.getMessage());
          }

        } catch (java.io.FileNotFoundException fnfExec) {

          javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), fnfExec.getMessage());
        }
      } catch (com.lowagie.text.DocumentException lwDocexec) {

        javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), lwDocexec.getMessage());
      }

      try {

        if (System.getProperty("os.name").equalsIgnoreCase("Linux")) {

          System.out.println(tempFile);

          //                    wait_for_Pdf2Show = rt.exec("kghostview "+tempFile+"");
          wait_for_Pdf2Show = rt.exec("kword " + tempFile + "");

          //                    wait_for_Pdf2Show = rt.exec("cat kghostview "+tempFile+"");

          wait_for_Pdf2Show.waitFor();

        } else if (System.getProperty("os.name").equalsIgnoreCase("Windows 98")) {

          wait_for_Pdf2Show = rt.exec("command.exe /C AcroRd32 /p /h " + tempFile);

          wait_for_Pdf2Show.waitFor();
          // wait_for_Pdf2Show = rt.exec("c:/Program Files/Adobe/Acrobat 5.0/Reader/AcroRd32.exe
          // "+tempFile);

          // wait_for_Pdf2Show.waitFor();

        } else {

          wait_for_Pdf2Show = rt.exec("cmd.exe /C AcroRd32 /p /h " + tempFile);

          wait_for_Pdf2Show.waitFor();
          // wait_for_Pdf2Show = rt.exec("c:/Program Files/Adobe/Acrobat 5.0/Reader/AcroRd32.exe
          // "+tempFile);

          // wait_for_Pdf2Show.waitFor();

        }

      } catch (java.lang.InterruptedException intrExec) {

        javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), intrExec.getMessage());
      }

    } catch (java.io.IOException IOexec) {

      javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), IOexec.getMessage());
    }
  }