use of org.apache.poi.ss.usermodel.ClientAnchor in project poi by apache.
the class TestHSSFPicture method bug49658.
@SuppressWarnings("resource")
@Test
public void bug49658() throws IOException {
// test if inserted EscherMetafileBlip will be read again
HSSFWorkbook wb = new HSSFWorkbook();
byte[] pictureDataEmf = POIDataSamples.getDocumentInstance().readFile("vector_image.emf");
int indexEmf = wb.addPicture(pictureDataEmf, HSSFWorkbook.PICTURE_TYPE_EMF);
byte[] pictureDataPng = POIDataSamples.getSpreadSheetInstance().readFile("logoKarmokar4.png");
int indexPng = wb.addPicture(pictureDataPng, HSSFWorkbook.PICTURE_TYPE_PNG);
byte[] pictureDataWmf = POIDataSamples.getSlideShowInstance().readFile("santa.wmf");
int indexWmf = wb.addPicture(pictureDataWmf, HSSFWorkbook.PICTURE_TYPE_WMF);
HSSFSheet sheet = wb.createSheet();
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
CreationHelper ch = wb.getCreationHelper();
ClientAnchor anchor = ch.createClientAnchor();
anchor.setCol1(2);
anchor.setCol2(5);
anchor.setRow1(1);
anchor.setRow2(6);
patriarch.createPicture(anchor, indexEmf);
anchor = ch.createClientAnchor();
anchor.setCol1(2);
anchor.setCol2(5);
anchor.setRow1(10);
anchor.setRow2(16);
patriarch.createPicture(anchor, indexPng);
anchor = ch.createClientAnchor();
anchor.setCol1(6);
anchor.setCol2(9);
anchor.setRow1(1);
anchor.setRow2(6);
patriarch.createPicture(anchor, indexWmf);
wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
byte[] pictureDataOut = wb.getAllPictures().get(0).getData();
assertArrayEquals(pictureDataEmf, pictureDataOut);
byte[] wmfNoHeader = new byte[pictureDataWmf.length - 22];
System.arraycopy(pictureDataWmf, 22, wmfNoHeader, 0, pictureDataWmf.length - 22);
pictureDataOut = wb.getAllPictures().get(2).getData();
assertArrayEquals(wmfNoHeader, pictureDataOut);
wb.close();
}
use of org.apache.poi.ss.usermodel.ClientAnchor in project poi by apache.
the class TestXSSFManualLayout method createEmptyLayout.
@Before
public void createEmptyLayout() {
wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet();
Drawing<?> drawing = sheet.createDrawingPatriarch();
ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
Chart chart = drawing.createChart(anchor);
ChartLegend legend = chart.getOrCreateLegend();
layout = legend.getManualLayout();
}
use of org.apache.poi.ss.usermodel.ClientAnchor in project poi by apache.
the class TestXSSFScatterChartData method testOneSeriePlot.
@Test
public void testOneSeriePlot() throws IOException {
Workbook wb = new XSSFWorkbook();
Sheet sheet = new SheetBuilder(wb, plotData).build();
Drawing<?> drawing = sheet.createDrawingPatriarch();
ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
Chart chart = drawing.createChart(anchor);
ChartAxis bottomAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.BOTTOM);
ChartAxis leftAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.LEFT);
ScatterChartData scatterChartData = chart.getChartDataFactory().createScatterChartData();
ChartDataSource<String> xs = DataSources.fromStringCellRange(sheet, CellRangeAddress.valueOf("A1:J1"));
ChartDataSource<Number> ys = DataSources.fromNumericCellRange(sheet, CellRangeAddress.valueOf("A2:J2"));
ScatterChartSeries series = scatterChartData.addSerie(xs, ys);
assertNotNull(series);
assertEquals(1, scatterChartData.getSeries().size());
assertTrue(scatterChartData.getSeries().contains(series));
chart.plot(scatterChartData, bottomAxis, leftAxis);
wb.close();
}
use of org.apache.poi.ss.usermodel.ClientAnchor in project poi by apache.
the class TestXSSFChartLegend method test_setOverlay_defaultChartLegend_expectOverlayInitialValueSetToFalse.
@Test
public void test_setOverlay_defaultChartLegend_expectOverlayInitialValueSetToFalse() throws IOException {
// Arrange
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet();
Drawing<?> drawing = sheet.createDrawingPatriarch();
ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
Chart chart = drawing.createChart(anchor);
ChartLegend legend = chart.getOrCreateLegend();
// Act
// Assert
assertFalse(legend.isOverlay());
wb.close();
}
use of org.apache.poi.ss.usermodel.ClientAnchor in project ocvn by devgateway.
the class ExcelChartSheetDefault method createChartAndLegend.
/**
* Creates a chart and also attaches a legend to it.
*/
@Override
public Chart createChartAndLegend() {
final Drawing drawing = excelSheet.createDrawingPatriarch();
final ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, 5, 15, 25);
final Chart chart = drawing.createChart(anchor);
final ChartLegend legend = chart.getOrCreateLegend();
legend.setPosition(LegendPosition.BOTTOM);
return chart;
}
Aggregations