Package org.pdfclown.documents.contents.objects

Examples of org.pdfclown.documents.contents.objects.ShowSimpleText


        frame[1] = state.textToDeviceSpace(new Point2D.Double(width,descent),true);
        frame[2] = state.textToDeviceSpace(new Point2D.Double(width,height+descent),true);
        frame[3] = state.textToDeviceSpace(new Point2D.Double(0,height+descent),true);

        // Add the text!
        add(new ShowSimpleText(font.encode(value)));
      }
      catch(Exception e)
      {throw new RuntimeException("Failed to show text.", e);}
      finally
      {end(); /* Ends the text object. */}
    }
    else
    {
      beginLocalState();
      try
      {
        // Coordinates transformation.
        double cos, sin;
        if(rotation == 0)
        {
          cos = 1;
          sin = 0;
        }
        else
        {
          double rad = rotation * Math.PI / 180.0;
          cos = Math.cos(rad);
          sin = Math.sin(rad);
        }
        // Apply the transformation!
        applyMatrix(
          cos,
          sin,
          -sin,
          cos,
          x,
          scanner.getContentContext().getBox().getHeight() - y
          );

        beginText();
        try
        {
          // Text coordinates adjustment.
          switch(alignmentX)
          {
            case Left:
              x = 0;
              break;
            case Right:
              x = -width;
              break;
            case Center:
            case Justify:
              x = -width / 2;
              break;
          }
          switch(alignmentY)
          {
            case Top:
              y = -font.getAscent(fontSize);
              break;
            case Bottom:
              y = height - font.getAscent(fontSize);
              break;
            case Middle:
              y = height / 2 - font.getAscent(fontSize);
              break;
          }
          // Apply the text coordinates adjustment!
          translateText(x,y);

          state = scanner.getState();
          frame[0] = state.textToDeviceSpace(new Point2D.Double(0,descent),true);
          frame[1] = state.textToDeviceSpace(new Point2D.Double(width,descent),true);
          frame[2] = state.textToDeviceSpace(new Point2D.Double(width,height+descent),true);
          frame[3] = state.textToDeviceSpace(new Point2D.Double(0,height+descent),true);

          // Add the text!
          add(new ShowSimpleText(font.encode(value)));
        }
        catch(Exception e)
        {throw new RuntimeException("Failed to show text.", e);}
        finally
        {end(); /* Ends the text object. */}
 
View Full Code Here

TOP

Related Classes of org.pdfclown.documents.contents.objects.ShowSimpleText

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.