<<<<<< abstract public class DiagramGenerator { <<<<<< <<<<<< <<<<<< <<<<<< final public ImageDescriptor createConstrainedSWTImageDecriptorForParts (List editParts, int maxDeviceWidth, int maxDeviceHeight, boolean useMargins) { ImageDescriptor imageDesc = new ImageDescriptor () { <<<<<< } ; Graphics graphics = null; try { IMapMode mm = getMapMode (); Rectangle originalBounds = new PrecisionRectangle (new Rectangle (calculateImageRectangle (editParts))); getMapMode ().LPtoDP (originalBounds); int deviceMargins = mm.LPtoDP (getImageMargin ()); int threshold = useMargins ? deviceMargins : 0; double xScalingFactor = 1.0, yScalingFactor = xScalingFactor; originalBounds.shrink (deviceMargins, deviceMargins); if (maxDeviceWidth > threshold) { xScalingFactor = (maxDeviceWidth - threshold - threshold) / (originalBounds.preciseWidth ()); } if (maxDeviceHeight > threshold) { yScalingFactor = (maxDeviceHeight - threshold - threshold) / (originalBounds.preciseHeight ()); } double scalingFactor = Math.min (Math.min (xScalingFactor, yScalingFactor), 1); int imageWidth = originalBounds.width + threshold + threshold; int imageHeight = originalBounds.height + threshold + threshold; if (scalingFactor < 1) { imageWidth = (int) Math.round (originalBounds.preciseWidth () * scalingFactor) + threshold + threshold; imageHeight = (int) Math.round (originalBounds.preciseHeight () * scalingFactor) + threshold + threshold; } graphics = setUpGraphics (imageWidth, imageHeight); ScaledGraphics scaledGraphics = new ScaledGraphics (graphics); RenderedMapModeGraphics mapModeGraphics = new RenderedMapModeGraphics (scaledGraphics, getMapMode ()); graphics.translate (threshold, threshold); mapModeGraphics.scale (scalingFactor); Point location = new PrecisionPoint (originalBounds.preciseX (), originalBounds.preciseY ()); mm.DPtoLP (location); renderToGraphics (mapModeGraphics, location, editParts); imageDesc = getImageDescriptor (graphics); } finally { if (graphics != null) disposeGraphics (graphics); } return imageDesc; } <<<<<< <<<<<< <<<<<< <<<<<< <<<<<< <<<<<< <<<<<< <<<<<< <<<<<< <<<<<< <<<<<< <<<<<< <<<<<< <<<<<< } >>>>>> abstract public class DiagramGenerator { >>>>>> >>>>>> >>>>>> >>>>>> final public ImageDescriptor createConstrainedSWTImageDecriptorForParts (List editParts, int maxDeviceWidth, int maxDeviceHeight, boolean useMargins) { ImageDescriptor imageDesc = new ImageDescriptor () { >>>>>> } ; Graphics graphics = null; try { IMapMode mm = getMapMode (); ConstrainedImageRenderingData data = getConstrainedImageRenderingData (editParts, maxDeviceWidth, maxDeviceHeight, useMargins); graphics = setUpGraphics (data.imageWidth, data.imageHeight); ScaledGraphics scaledGraphics = new ScaledGraphics (graphics); RenderedMapModeGraphics mapModeGraphics = new RenderedMapModeGraphics (scaledGraphics, getMapMode ()); graphics.translate (data.margin, data.margin); mapModeGraphics.scale (data.scalingFactor); Point location = new PrecisionPoint (data.imageOriginalBounds.preciseX (), data.imageOriginalBounds.preciseY ()); mm.DPtoLP (location); renderToGraphics (mapModeGraphics, location, editParts); imageDesc = getImageDescriptor (graphics); } finally { if (graphics != null) disposeGraphics (graphics); } return imageDesc; } >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> public List < PartPositionInfo > getConstrainedDiagramPartInfo (DiagramEditPart diagramEditPart, int maxWidth, int maxHeight, boolean useMargins); public List < PartPositionInfo > getConstrainedDiagramPartInfo (int maxWidth, int maxHeight, boolean useMargins); >>>>>> >>>>>> >>>>>> }