use of org.apache.poi.hwmf.record.HwmfMapMode in project poi by apache.
the class HwmfGraphics method updateWindowMapMode.
/**
* After setting various window and viewport related properties,
* the underlying graphics context needs to be adapted.
* This methods gathers and sets the corresponding graphics transformations.
*/
public void updateWindowMapMode() {
Rectangle2D win = prop.getWindow();
HwmfMapMode mapMode = prop.getMapMode();
graphicsCtx.setTransform(initialAT);
switch(mapMode) {
default:
case MM_ANISOTROPIC:
// scale window bounds to output bounds
graphicsCtx.scale(bbox.getWidth() / win.getWidth(), bbox.getHeight() / win.getHeight());
graphicsCtx.translate(-win.getX(), -win.getY());
break;
case MM_ISOTROPIC:
// TODO: to be validated ...
// like anisotropic, but use x-axis as reference
graphicsCtx.scale(bbox.getWidth() / win.getWidth(), bbox.getWidth() / win.getWidth());
graphicsCtx.translate(-win.getX(), -win.getY());
break;
case MM_LOMETRIC:
case MM_HIMETRIC:
case MM_LOENGLISH:
case MM_HIENGLISH:
case MM_TWIPS:
{
// TODO: to be validated ...
GraphicsConfiguration gc = graphicsCtx.getDeviceConfiguration();
graphicsCtx.transform(gc.getNormalizingTransform());
graphicsCtx.scale(1. / mapMode.scale, -1. / mapMode.scale);
graphicsCtx.translate(-win.getX(), -win.getY());
break;
}
case MM_TEXT:
// TODO: to be validated ...
break;
}
}
Aggregations