Example usage for org.apache.poi.ss.usermodel ClientAnchor getDy2

List of usage examples for org.apache.poi.ss.usermodel ClientAnchor getDy2

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel ClientAnchor getDy2.

Prototype

public int getDy2();

Source Link

Document

Sets the y coordinate within the second cell Note - XSSF and HSSF have a slightly different coordinate system, values in XSSF are larger by a factor of org.apache.poi.util.Units#EMU_PER_PIXEL

Usage

From source file:org.pentaho.reporting.engine.classic.core.bugs.Prd3278IT.java

License:Open Source License

@Test
public void testImageAligningToCells() {
    TableRectangle rect = new TableRectangle();
    rect.setRect(1, 1, 2, 2);/*from w  ww  .j ava 2s  .  c  o m*/
    StrictBounds b = new StrictBounds(StrictGeomUtility.toInternalValue(100),
            StrictGeomUtility.toInternalValue(100), StrictGeomUtility.toInternalValue(400),
            StrictGeomUtility.toInternalValue(400));
    ClientAnchor clientAnchor = imageHandler.computeClientAnchor(sheetLayout, rect, b);
    Assert.assertEquals(1, clientAnchor.getCol1());
    Assert.assertEquals(1, clientAnchor.getCol2());
    Assert.assertEquals(1, clientAnchor.getRow1());
    Assert.assertEquals(1, clientAnchor.getRow2());

    Assert.assertEquals(0, clientAnchor.getDx1());
    Assert.assertEquals(1023, clientAnchor.getDx2());
    Assert.assertEquals(0, clientAnchor.getDy1());
    Assert.assertEquals(255, clientAnchor.getDy2());
}

From source file:org.pentaho.reporting.engine.classic.core.bugs.Prd3278IT.java

License:Open Source License

@Test
public void testImageAligningLeftAndTop() {
    TableRectangle rect = new TableRectangle();
    rect.setRect(1, 1, 2, 2);/*from w  w  w.j a v a  2  s.co  m*/
    StrictBounds b = new StrictBounds(StrictGeomUtility.toInternalValue(100),
            StrictGeomUtility.toInternalValue(100), StrictGeomUtility.toInternalValue(300),
            StrictGeomUtility.toInternalValue(300));

    ClientAnchor clientAnchor = imageHandler.computeClientAnchor(sheetLayout, rect, b);
    Assert.assertEquals(1, clientAnchor.getCol1());
    Assert.assertEquals(1, clientAnchor.getCol2());
    Assert.assertEquals(1, clientAnchor.getRow1());
    Assert.assertEquals(1, clientAnchor.getRow2());

    Assert.assertEquals(0, clientAnchor.getDx1());
    Assert.assertEquals(1023 * 3 / 4, clientAnchor.getDx2());
    Assert.assertEquals(0, clientAnchor.getDy1());
    Assert.assertEquals(255 * 3 / 4, clientAnchor.getDy2());
}

From source file:org.pentaho.reporting.engine.classic.core.bugs.Prd3278IT.java

License:Open Source License

@Test
public void testImageAligningMiddle() {
    TableRectangle rect = new TableRectangle();
    rect.setRect(1, 1, 2, 2);/*from   ww  w  .  j a v  a 2 s . c o  m*/
    StrictBounds b = new StrictBounds(StrictGeomUtility.toInternalValue(200),
            StrictGeomUtility.toInternalValue(200), StrictGeomUtility.toInternalValue(200),
            StrictGeomUtility.toInternalValue(200));

    ClientAnchor clientAnchor = imageHandler.computeClientAnchor(sheetLayout, rect, b);
    Assert.assertEquals(1, clientAnchor.getCol1());
    Assert.assertEquals(1, clientAnchor.getCol2());
    Assert.assertEquals(1, clientAnchor.getRow1());
    Assert.assertEquals(1, clientAnchor.getRow2());

    Assert.assertEquals(255, clientAnchor.getDx1());
    Assert.assertEquals(1023 * 3 / 4, clientAnchor.getDx2());
    Assert.assertEquals(63, clientAnchor.getDy1());
    Assert.assertEquals(255 * 3 / 4, clientAnchor.getDy2());
}

From source file:org.pentaho.reporting.engine.classic.core.bugs.Prd3278IT.java

License:Open Source License

@Test
public void testImageAligningToCellsXLSX() {
    TableRectangle rect = new TableRectangle();
    rect.setRect(1, 1, 2, 2);// w w w  .j ava 2  s  .  com
    StrictBounds b = new StrictBounds(StrictGeomUtility.toInternalValue(100),
            StrictGeomUtility.toInternalValue(100), StrictGeomUtility.toInternalValue(400),
            StrictGeomUtility.toInternalValue(400));
    ClientAnchor clientAnchor = xlsxImageHandler.computeClientAnchor(sheetLayout, rect, b);
    Assert.assertEquals(1, clientAnchor.getCol1());
    Assert.assertEquals(1, clientAnchor.getCol2());
    Assert.assertEquals(1, clientAnchor.getRow1());
    Assert.assertEquals(1, clientAnchor.getRow2());

    Assert.assertEquals(0, clientAnchor.getDx1());
    Assert.assertEquals(400 * XSSFShape.EMU_PER_POINT, clientAnchor.getDx2());
    Assert.assertEquals(0, clientAnchor.getDy1());
    Assert.assertEquals(400 * XSSFShape.EMU_PER_POINT, clientAnchor.getDy2());
}

From source file:org.pentaho.reporting.engine.classic.core.bugs.Prd3278IT.java

License:Open Source License

@Test
public void testImageAligningLeftAndTopXLSX() {
    TableRectangle rect = new TableRectangle();
    rect.setRect(1, 1, 2, 2);/*ww w  .  jav  a 2s .  co m*/
    StrictBounds b = new StrictBounds(StrictGeomUtility.toInternalValue(100),
            StrictGeomUtility.toInternalValue(100), StrictGeomUtility.toInternalValue(300),
            StrictGeomUtility.toInternalValue(300));

    ClientAnchor clientAnchor = xlsxImageHandler.computeClientAnchor(sheetLayout, rect, b);
    Assert.assertEquals(1, clientAnchor.getCol1());
    Assert.assertEquals(1, clientAnchor.getCol2());
    Assert.assertEquals(1, clientAnchor.getRow1());
    Assert.assertEquals(1, clientAnchor.getRow2());

    Assert.assertEquals(0, clientAnchor.getDx1());
    Assert.assertEquals(300 * XSSFShape.EMU_PER_POINT, clientAnchor.getDx2());
    Assert.assertEquals(0, clientAnchor.getDy1());
    Assert.assertEquals(300 * XSSFShape.EMU_PER_POINT, clientAnchor.getDy2());
}

From source file:org.pentaho.reporting.engine.classic.core.bugs.Prd3278IT.java

License:Open Source License

@Test
public void testImageAligningMiddleXLSX() {
    TableRectangle rect = new TableRectangle();
    rect.setRect(1, 1, 2, 2);/*from  w ww.ja  va2  s.c o m*/
    StrictBounds b = new StrictBounds(StrictGeomUtility.toInternalValue(200),
            StrictGeomUtility.toInternalValue(200), StrictGeomUtility.toInternalValue(200),
            StrictGeomUtility.toInternalValue(200));

    ClientAnchor clientAnchor = xlsxImageHandler.computeClientAnchor(sheetLayout, rect, b);
    Assert.assertEquals(1, clientAnchor.getCol1());
    Assert.assertEquals(1, clientAnchor.getCol2());
    Assert.assertEquals(1, clientAnchor.getRow1());
    Assert.assertEquals(1, clientAnchor.getRow2());

    Assert.assertEquals(100 * XSSFShape.EMU_PER_POINT, clientAnchor.getDx1());
    Assert.assertEquals(300 * XSSFShape.EMU_PER_POINT, clientAnchor.getDx2());
    Assert.assertEquals(100 * XSSFShape.EMU_PER_POINT, clientAnchor.getDy1());
    Assert.assertEquals(300 * XSSFShape.EMU_PER_POINT, clientAnchor.getDy2());
}

From source file:org.tiefaces.components.websheet.utility.PicturesUtility.java

License:MIT License

/**
 * Gets the anchor size.// w  ww.  ja va2 s.co  m
 *
 * @param sheet1
 *            the sheet 1
 * @param fcell
 *            the fcell
 * @param cell
 *            the cell
 * @param anchor
 *            the anchor
 * @return the anchor size
 */
public static AnchorSize getAnchorSize(final Sheet sheet1, final FacesCell fcell, final Cell cell,
        final ClientAnchor anchor) {

    if (!(sheet1 instanceof XSSFSheet)) {
        return null;
    }
    double picWidth = 0.0;
    double picHeight = 0.0;
    int left = anchor.getDx1() / org.apache.poi.util.Units.EMU_PER_PIXEL;
    int top = (int) ((double) anchor.getDy1() / org.apache.poi.util.Units.EMU_PER_PIXEL
            / WebSheetUtility.PICTURE_HEIGHT_ADJUST);
    int right = anchor.getDx2() / org.apache.poi.util.Units.EMU_PER_PIXEL;
    int bottom = (int) ((double) anchor.getDy2() / org.apache.poi.util.Units.EMU_PER_PIXEL
            / WebSheetUtility.PICTURE_HEIGHT_ADJUST);

    double cellWidth = 0.0;
    double cellHeight = 0.0;

    if ((cell != null) && (fcell != null)) {
        for (int col = cell.getColumnIndex(); col < cell.getColumnIndex() + fcell.getColspan(); col++) {
            cellWidth += sheet1.getColumnWidthInPixels(col);
        }
        double lastCellWidth = sheet1.getColumnWidthInPixels(cell.getColumnIndex() + fcell.getColspan() - 1);

        for (int rowIndex = cell.getRowIndex(); rowIndex < cell.getRowIndex()
                + fcell.getRowspan(); rowIndex++) {
            cellHeight += WebSheetUtility.pointsToPixels(sheet1.getRow(rowIndex).getHeightInPoints());
        }
        double lastCellHeight = WebSheetUtility
                .pointsToPixels(sheet1.getRow(cell.getRowIndex() + fcell.getRowspan() - 1).getHeightInPoints());

        picWidth = cellWidth - lastCellWidth + right - left;
        picHeight = cellHeight - lastCellHeight + bottom - top;
    } else {
        for (short col = anchor.getCol1(); col < anchor.getCol2(); col++) {
            picWidth += sheet1.getColumnWidthInPixels(col);
        }
        for (int rowindex = anchor.getRow1(); rowindex < anchor.getRow2(); rowindex++) {
            Row row = sheet1.getRow(rowindex);
            if (row != null) {
                picHeight += WebSheetUtility.pointsToPixels(row.getHeightInPoints());
            }
        }
    }

    return new AnchorSize(left, top, (int) picWidth, (int) picHeight, cellWidth, cellHeight);

}