2 Replies Latest reply: Feb 29, 2012 4:27 AM by 908385 RSS

    Printing of the image display area is to small 2 read large displays

    908385
      Printing of the image display area is to small to read on some large displays

      Need to restrict the image resizing in generating the print output to a minimum size (to allow it to be readable) and allow the printed output to flow into a multiple pages wide by multiple pages in length if necessary. Currently it is restricted to one page.

      below is the code

      *public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException {*
      if (pageIndex != 0)
      return NO_SUCH_PAGE;

      Graphics2D g2d = (Graphics2D) g;

      Rectangle2D.Double printBounds = new Rectangle2D.Double(
      pageFormat.getImageableX(),
      pageFormat.getImageableY(),
      pageFormat.getImageableWidth(),
      pageFormat.getImageableHeight()
      *);*

      *// Print the header and reduce the height for printing*
      float headerHeight = printHeader(printBounds, g2d);
      printBounds.y += headerHeight;
      printBounds.height -= headerHeight;

      *// Carve off the amount of space needed for the footer*
      printBounds.height -= getFooterHeight(g2d);

      *// Print the nodes and edges*
      printDisplay( printBounds, g2d, 0 );

      *if (footer != null) {*
      printBounds.y += (printBounds.height + 15);
      printFooter(printBounds, g2d);
      *}*

      return PAGE_EXISTS;
      *}*


      =================================

      *protected void printDisplay( Rectangle2D.Double printBounds, Graphics2D g2d, double margin ) {*
      *// Get a rectangle that represents the bounds of all of the DisplayEntities*
      Rectangle r = null;
      *for (Enumeration e=displayManager.getEntitySet().getEntityEnumerati on();e.hasMoreElements();) {*
      DisplayEntity de = (DisplayEntity)e.nextElement();
      if (r == null)
      r = de.getBounds();
      else
      r = r.union(de.getBounds());
      *}*

      *// Get that as doubles, rather than ints, and expand by half the margin*
      *// height in all directions*
      Rectangle2D.Double entityBounds = new Rectangle2D.Double(r.x,r.y,r.width,r.height);
      entityBounds.x -= margin/2;
      entityBounds.y -= margin/2;
      entityBounds.width += margin;
      entityBounds.height += margin;

      *// See if height and/or width was specified*
      Unit specifiedSize = configuration.getHeight();
      double printHeight = (specifiedSize != null) ?
      specifiedSize.getValueAsPixels((int)printBounds.he ight) :
      printBounds.height;

      specifiedSize = configuration.getWidth();
      double printWidth = (specifiedSize != null) ?
      specifiedSize.getValueAsPixels((int)printBounds.wi dth) :
      printBounds.width;

      *// Figure out the ratio of print-bounds to the entities' bounds*
      double scaleX = 1;
      double scaleY = 1;

      *// See if we need to scale*
      boolean canExpand = configuration.expandToFit();
      boolean canShrink = configuration.shrinkToFit();

      *if (canExpand == false && canShrink == false) {*
      scaleX = scaleY = configuration.getScale();
      *}*
      *else {*
      if ((canShrink && canExpand) ||
      *(canShrink &&*
      *(entityBounds.width > printWidth ||*
      entityBounds.height > printHeight)) ||
      *(canExpand &&*
      *(entityBounds.width < printWidth ||*
      *entityBounds.height < printHeight))) {*
      scaleX = printWidth / entityBounds.width;
      scaleY = printHeight / entityBounds.height;
      *}*
      *}*

      *if (configuration.maintainAspectRatio()) { // Scale the same*
      if (scaleX > scaleY)
      scaleX = scaleY;
      else
      scaleY = scaleX;
      *}*


      above methods am using for printing image. but in large display i cant able to read letters.


      Thanks in advance

      Srini