Java Code Examples for javax.print.attribute.standard.OrientationRequested#PORTRAIT

The following examples show how to use javax.print.attribute.standard.OrientationRequested#PORTRAIT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExportConfig.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
public ExportConfig(String fontFamily, String fontSize,
		String orientation) {
	super();
	this.fontFamily = fontFamily;
	if(fontSize!=null){
		try {
			this.fontSize = new Integer(fontSize);
		} catch (Exception e) {
			this.fontSize = null;
			logger.error("Invalid export fontSize. It has to be a number, but fount ["+fontSize+"]");
		}
	}
	
	if(orientation.equals("PORTRAIT")){
		this.orientation =OrientationRequested.PORTRAIT;
	}
	
	if(orientation.equals("LANDSCAPE")){
		this.orientation =OrientationRequested.LANDSCAPE;
	}
	
	if(orientation.equals("REVERSE_LANDSCAPE")){
		this.orientation =OrientationRequested.REVERSE_LANDSCAPE;	
	}
	
	if(orientation.equals("REVERSE_PORTRAIT")){
		this.orientation =OrientationRequested.REVERSE_PORTRAIT; 
	}
}
 
Example 2
Source File: DummyPrintService.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public Object getDefaultAttributeValue(Class<? extends Attribute> category) {
    if (category == Media.class) {
        return MediaSizeName.NA_LETTER;
    }
    if (category == OrientationRequested.class) {
        return OrientationRequested.PORTRAIT;
    }
    return null;
}
 
Example 3
Source File: DummyPrintService.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public Object getSupportedAttributeValues(Class<? extends Attribute> category, DocFlavor flavor, AttributeSet attributes) {
    if (category == Media.class) {
        return new Media[]{MediaSizeName.NA_LETTER, MediaSizeName.NA_LEGAL, MediaSizeName.ISO_A4};
    }
    if (category == OrientationRequested.class) {
        return new OrientationRequested[]{OrientationRequested.PORTRAIT, OrientationRequested.LANDSCAPE};
    }
    return null;
}
 
Example 4
Source File: Java14PrintUtil.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static OrientationRequested mapOrientation( final int orientation ) {
  switch ( orientation ) {
    case PageFormat.LANDSCAPE:
      return OrientationRequested.LANDSCAPE;
    case PageFormat.REVERSE_LANDSCAPE:
      return OrientationRequested.REVERSE_LANDSCAPE;
    case PageFormat.PORTRAIT:
      return OrientationRequested.PORTRAIT;
    default:
      throw new IllegalArgumentException( "The given value is no valid PageFormat orientation." );
  }
}
 
Example 5
Source File: JRPrintServiceExporter.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void setOrientation(JasperPrint jPrint,PrintRequestAttributeSet printRequestAttributeSet)
{
	if (!printRequestAttributeSet.containsKey(MediaPrintableArea.class))
	{
		int printableWidth;
		int printableHeight;
		switch (jPrint.getOrientationValue())
		{
			case LANDSCAPE:
				printableWidth = jPrint.getPageHeight();
				printableHeight = jPrint.getPageWidth();
				break;
			default:
				printableWidth = jPrint.getPageWidth();
				printableHeight = jPrint.getPageHeight();
				break;
		}
		
		printRequestAttributeSet.add(
			new MediaPrintableArea(
				0f, 
				0f, 
				printableWidth / 72f,
				printableHeight / 72f,
				MediaPrintableArea.INCH
				)
			);
	}

	if (!printRequestAttributeSet.containsKey(OrientationRequested.class))
	{
		OrientationRequested orientation;
		switch (jPrint.getOrientationValue())
		{
			case LANDSCAPE:
				orientation = OrientationRequested.LANDSCAPE;
				break;
			default:
				orientation = OrientationRequested.PORTRAIT;
				break;
		}
		printRequestAttributeSet.add(orientation);
	}
	
}