/** * Resize the image proportionally. * * @see #resize(double, double) */ @Override public void resize(double scale) { resize(scale,scale); }
/** * Reset the image to the dimension of the embedded image * * <p> * Please note, that this method works correctly only for workbooks * with default font size (Arial 10pt for .xls). * If the default font is changed the resized image can be streched vertically or horizontally. * </p> */ @Override public void resize(){ resize(Double.MAX_VALUE); }
/** * Reset the image to the original size. * * <p> * Please note, that this method works correctly only for workbooks * with default font size (Arial 10pt for .xls). * If the default font is changed the resized image can be streched vertically or horizontally. * </p> */ public void resize(){ resize(1.0); }
/** * Reset the image to the original size. * * <p> * Please note, that this method works correctly only for workbooks * with default font size (Arial 10pt for .xls). * If the default font is changed the resized image can be streched vertically or horizontally. * </p> */ public void resize(){ resize(1.0); }
/** * Reset the image to the dimension of the embedded image * * <p> * Please note, that this method works correctly only for workbooks * with default font size (Arial 10pt for .xls). * If the default font is changed the resized image can be streched vertically or horizontally. * </p> */ @Override public void resize(){ resize(Double.MAX_VALUE); }
/** * Resize the image proportionally. * * @see #resize(double, double) */ @Override public void resize(double scale) { resize(scale,scale); }
@Override public void inlineToXls(HSSFPatriarch patriarch, HSSFCell resultCell, Object paramValue, Matcher paramsMatcher) { try { Image image = new Image(paramValue, paramsMatcher); if (image.isValid()) { HSSFSheet sheet = resultCell.getSheet(); HSSFWorkbook workbook = sheet.getWorkbook(); int pictureIdx = workbook.addPicture(image.imageContent, Workbook.PICTURE_TYPE_JPEG); CreationHelper helper = workbook.getCreationHelper(); ClientAnchor anchor = helper.createClientAnchor(); anchor.setCol1(resultCell.getColumnIndex()); anchor.setRow1(resultCell.getRowIndex()); anchor.setCol2(resultCell.getColumnIndex()); anchor.setRow2(resultCell.getRowIndex()); if (patriarch == null) { throw new IllegalArgumentException(String.format("No HSSFPatriarch object provided. Charts on this sheet could cause this effect. Please check sheet %s", resultCell.getSheet().getSheetName())); } HSSFPicture picture = patriarch.createPicture(anchor, pictureIdx); Dimension size = ImageUtils.getDimensionFromAnchor(picture); double actualHeight = size.getHeight() / EMU_PER_PIXEL; double actualWidth = size.getWidth() / EMU_PER_PIXEL; picture.resize((double) image.width / actualWidth, (double) image.height / actualHeight); } } catch (IllegalArgumentException e) { throw new ReportFormattingException("An error occurred while inserting bitmap to xls file", e); } }
@Override public void inlineToXls(HSSFPatriarch patriarch, HSSFCell resultCell, Object paramValue, Matcher paramsMatcher) { try { Image image = new Image(paramValue, paramsMatcher); if (image.isValid()) { HSSFSheet sheet = resultCell.getSheet(); HSSFWorkbook workbook = sheet.getWorkbook(); int pictureIdx = workbook.addPicture(image.imageContent, Workbook.PICTURE_TYPE_JPEG); CreationHelper helper = workbook.getCreationHelper(); ClientAnchor anchor = helper.createClientAnchor(); anchor.setCol1(resultCell.getColumnIndex()); anchor.setRow1(resultCell.getRowIndex()); anchor.setCol2(resultCell.getColumnIndex()); anchor.setRow2(resultCell.getRowIndex()); if (patriarch == null) { throw new IllegalArgumentException(String.format("No HSSFPatriarch object provided. Charts on this sheet could cause this effect. Please check sheet %s", resultCell.getSheet().getSheetName())); } HSSFPicture picture = patriarch.createPicture(anchor, pictureIdx); Dimension size = ImageUtils.getDimensionFromAnchor(picture); double actualHeight = size.getHeight() / EMU_PER_PIXEL; double actualWidth = size.getWidth() / EMU_PER_PIXEL; picture.resize((double) image.width / actualWidth, (double) image.height / actualHeight); } } catch (IllegalArgumentException e) { throw new ReportFormattingException("An error occurred while inserting bitmap to xls file", e); } }
private static void drawSheet5( HSSFSheet sheet5, HSSFWorkbook wb ) throws IOException { // Create the drawing patriarch. This is the top level container for // all shapes. This will clear out any existing shapes for that sheet. HSSFPatriarch patriarch = sheet5.createDrawingPatriarch(); HSSFClientAnchor anchor; anchor = new HSSFClientAnchor(0,0,0,255,(short)2,2,(short)4,7); anchor.setAnchorType( AnchorType.MOVE_DONT_RESIZE ); patriarch.createPicture(anchor, loadPicture( "src/resources/logos/logoKarmokar4.png", wb )); anchor = new HSSFClientAnchor(0,0,0,255,(short)4,2,(short)5,7); anchor.setAnchorType( AnchorType.MOVE_DONT_RESIZE ); patriarch.createPicture(anchor, loadPicture( "src/resources/logos/logoKarmokar4edited.png", wb )); anchor = new HSSFClientAnchor(0,0,1023,255,(short)6,2,(short)8,7); anchor.setAnchorType( AnchorType.MOVE_DONT_RESIZE ); HSSFPicture picture = patriarch.createPicture(anchor, loadPicture( "src/resources/logos/logoKarmokar4s.png", wb )); //Reset the image to the original size. picture.resize(); picture.setLineStyle( HSSFShape.LINESTYLE_DASHDOTGEL ); }