Package javax.print.attribute.standard

Examples of javax.print.attribute.standard.MediaSize$StaticData


                                                                 null, null);
            mpas = new MediaPrintableArea[media.length];
            for (int i=0; i< mpas.length; i++) {
                if (media[i] instanceof MediaSizeName) {
                    MediaSizeName msn = (MediaSizeName)media[i];
                    MediaSize mediaSize = MediaSize.getMediaSizeForName(msn);
                    if (mediaSize == null) {
                        mpas[i] = (MediaPrintableArea)
                            getDefaultAttributeValue(MediaPrintableArea.class);
                    } else {
                        mpas[i] = new MediaPrintableArea(0.25f, 0.25f,
                                        mediaSize.getX(MediaSize.INCH)-0.5f,
                                        mediaSize.getY(MediaSize.INCH)-0.5f,
                                        MediaSize.INCH);
                    }
                }
            }
        }
View Full Code Here


                // add custom if no matching standard media
                cupsMediaSNames[i] = msn;

                // add this new custom msn to MediaSize array
                if ((width > 0.0) && (length > 0.0)) {
                    new MediaSize(width, length,
                                  Size2DSyntax.INCH, msn);
                }
            }

            // add to list of custom MediaSizeName
View Full Code Here

        int tmp = x;
        x = y;
        y = tmp;
      }
      for( MediaSizeName name : MEDIA_NAMES ){
        MediaSize media = MediaSize.getMediaSizeForName(name);
        if( media != null ){
          if( Math.abs( x - media.getX(1) ) < MATCH_DIFF && Math.abs( y - media.getY(1) ) < MATCH_DIFF ){
            return name;
          }
        }
      }
      return null;
View Full Code Here

    }

    MediaSizeName bestMedia = null;
    float bestFit = Float.MAX_VALUE;
    for (MediaSizeName media : getSplitMedia()) {
      MediaSize mediaSize = MediaSize.getMediaSizeForName(media);
      if( mediaSize!=null ){
        if( DEBUGMODE ){
          System.out.print(mediaSize.toString(MediaSize.MM, "mm")); //$NON-NLS-1$
          System.out.println(" - " + media); //$NON-NLS-1$
        }
        float dy = mediaSize.getY(MediaSize.INCH) - height;
        float dx = mediaSize.getY(MediaSize.INCH) - width;
        float fit = dy + dx;
        if( dy >= 0 && dx >= 0 && fit <= bestFit ){
          bestFit = fit;
          bestMedia = media;
        }
      }
    }
    if( bestMedia==null ){
      bestMedia = MediaSize.findMedia(width, height, MediaSize.INCH);
      geco().debug(Messages.getString("SingleSplitPrinter.SmallTicketSizeWarning")); //$NON-NLS-1$
      if( DEBUGMODE ){
        System.out.print("Found: "); //$NON-NLS-1$
      }     
    } else {
      if( DEBUGMODE ){
        System.out.print("Chosen: "); //$NON-NLS-1$
      }     
    }
    if( bestMedia!=null ){
      attributes.add(bestMedia);
      MediaSize fitSize = MediaSize.getMediaSizeForName(bestMedia);
      if( DEBUGMODE ){
        System.out.println(fitSize.toString(MediaSize.MM, "mm")); //$NON-NLS-1$
      }
    } else {
      geco().log(Messages.getString("SingleSplitPrinter.NoMatchingTicketSizeWarning")); //$NON-NLS-1$
    }
  }
View Full Code Here

TOP

Related Classes of javax.print.attribute.standard.MediaSize$StaticData

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.