本文整理汇总了Java中org.eclipse.gef.GraphicalViewer.getContents方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicalViewer.getContents方法的具体用法?Java GraphicalViewer.getContents怎么用?Java GraphicalViewer.getContents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.gef.GraphicalViewer
的用法示例。
在下文中一共展示了GraphicalViewer.getContents方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setRuler
import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
private void setRuler(RulerProvider provider, int orientation) {
Object ruler = null;
if (isRulerVisible && provider != null)
// provider.getRuler() might return null (at least the API does not prevent that)
ruler = provider.getRuler();
if (ruler == null) {
// Ruler is not visible or is not present
setRulerContainer(null, orientation);
// Layout right-away to prevent an empty control from showing
layout(true);
return;
}
GraphicalViewer container = getRulerContainer(orientation);
if (container == null) {
container = createRulerContainer(orientation);
setRulerContainer(container, orientation);
}
if (container.getContents() != ruler) {
container.setContents(ruler);
needToLayout = true;
Display.getCurrent().asyncExec(runnable);
}
}
示例2: outputImage
import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
private ImageInfo outputImage(final ProgressMonitor monitor, final Display display, final Category category, final int format, final String fileName) throws Exception {
GraphicalViewer viewer = null;
ImageInfo imageInfo = null;
try {
String name = "All";
if (category != null) {
name = "category - " + category.getName();
}
monitor.subTaskWithCounter(ResourceString.getResourceString("dialog.message.export.image.creating") + " : " + name);
viewer = createGraphicalViewer(display, diagram);
imageInfo = createImage(display, viewer, format, fileName, diagram, category);
monitor.worked(1);
if (fileName != null) {
monitor.subTaskWithCounter(ResourceString.getResourceString("dialog.message.export.image.output") + " : " + fileName);
writeToFile(imageInfo);
monitor.worked(1);
} else {
imageInfo.toImageData();
}
return imageInfo;
} finally {
if (imageInfo != null) {
imageInfo.dispose();
}
if (viewer != null && viewer.getContents() != null) {
viewer.getContents().deactivate();
}
}
}
示例3: refreshElement
import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
/**
* Allow the refresh of a specific element of the editor
*/
public static void refreshElement(IEditorPart ep, PropertyChangeEvent event) {
if (ep == null)
return;
if (ep instanceof IGraphicalEditor) {
IGraphicalEditor ige = (IGraphicalEditor) ep;
GraphicalViewer gv = ige.getGraphicalViewer();
EditPart editor = gv.getContents();
if (editor instanceof ReportPageEditPart) {
((ReportPageEditPart) editor).propertyChange(event);
} else
editor.refresh();
}
}
示例4: createImage
import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
public static ImageInfo createImage(final GraphicalViewer viewer, final int format, final String path) {
GC figureCanvasGC = null;
GC imageGC = null;
try {
final ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) viewer.getRootEditPart();
rootEditPart.refresh();
final IFigure rootFigure = ((LayerManager) rootEditPart).getLayer(LayerConstants.PRINTABLE_LAYERS);
final EditPart editPart = viewer.getContents();
editPart.refresh();
final ERDiagram diagram = (ERDiagram) editPart.getModel();
final Rectangle rootFigureBounds = getBounds(diagram, rootEditPart, rootFigure.getBounds());
final Control figureCanvas = viewer.getControl();
figureCanvasGC = new GC(figureCanvas);
final Image img = new Image(Display.getCurrent(), rootFigureBounds.width + 20, rootFigureBounds.height + 20);
imageGC = new GC(img);
imageGC.setBackground(figureCanvasGC.getBackground());
imageGC.setForeground(figureCanvasGC.getForeground());
imageGC.setFont(figureCanvasGC.getFont());
imageGC.setLineStyle(figureCanvasGC.getLineStyle());
imageGC.setLineWidth(figureCanvasGC.getLineWidth());
imageGC.setAntialias(SWT.OFF);
// imageGC.setInterpolation(SWT.HIGH);
final Graphics imgGraphics = new SWTGraphics(imageGC);
imgGraphics.setBackgroundColor(figureCanvas.getBackground());
imgGraphics.fillRectangle(0, 0, rootFigureBounds.width + 20, rootFigureBounds.height + 20);
final int translateX = translateX(rootFigureBounds.x);
final int translateY = translateY(rootFigureBounds.y);
imgGraphics.translate(translateX, translateY);
rootFigure.paint(imgGraphics);
final Map<TableView, Location> tableLoacationMap = getTableLocationMap(rootEditPart, translateX, translateY, diagram);
final ImageInfo imageInfo = new ImageInfo(img, tableLoacationMap);
imageInfo.setFormat(format);
imageInfo.setPath(path);
return imageInfo;
} finally {
if (figureCanvasGC != null) {
figureCanvasGC.dispose();
}
if (imageGC != null) {
imageGC.dispose();
}
}
}
示例5: createImage
import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
public static ImageInfo createImage(GraphicalViewer viewer, int format,
String path) {
GC figureCanvasGC = null;
GC imageGC = null;
try {
ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) viewer
.getRootEditPart();
rootEditPart.refresh();
IFigure rootFigure = ((LayerManager) rootEditPart)
.getLayer(LayerConstants.PRINTABLE_LAYERS);
EditPart editPart = viewer.getContents();
editPart.refresh();
ERDiagram diagram = (ERDiagram) editPart.getModel();
Rectangle rootFigureBounds = getBounds(diagram, rootEditPart,
rootFigure.getBounds());
Control figureCanvas = viewer.getControl();
figureCanvasGC = new GC(figureCanvas);
Image img = new Image(Display.getCurrent(),
rootFigureBounds.width + 20, rootFigureBounds.height + 20);
imageGC = new GC(img);
imageGC.setBackground(figureCanvasGC.getBackground());
imageGC.setForeground(figureCanvasGC.getForeground());
imageGC.setFont(figureCanvasGC.getFont());
imageGC.setLineStyle(figureCanvasGC.getLineStyle());
imageGC.setLineWidth(figureCanvasGC.getLineWidth());
imageGC.setAntialias(SWT.OFF);
// imageGC.setInterpolation(SWT.HIGH);
Graphics imgGraphics = new SWTGraphics(imageGC);
imgGraphics.setBackgroundColor(figureCanvas.getBackground());
imgGraphics.fillRectangle(0, 0, rootFigureBounds.width + 20,
rootFigureBounds.height + 20);
int translateX = translateX(rootFigureBounds.x);
int translateY = translateY(rootFigureBounds.y);
imgGraphics.translate(translateX, translateY);
rootFigure.paint(imgGraphics);
Map<TableView, Location> tableLoacationMap = getTableLocationMap(
rootEditPart, translateX, translateY, diagram);
ImageInfo imageInfo = new ImageInfo(img, tableLoacationMap);
imageInfo.setFormat(format);
imageInfo.setPath(path);
return imageInfo;
} finally {
if (figureCanvasGC != null) {
figureCanvasGC.dispose();
}
if (imageGC != null) {
imageGC.dispose();
}
}
}
示例6: outputImage
import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
private ImageInfo outputImage(ProgressMonitor monitor, Display display,
Category category, int format, String fileName) throws Exception {
GraphicalViewer viewer = null;
ImageInfo imageInfo = null;
try {
String name = "All";
if (category != null) {
name = "category - " + category.getName();
}
monitor.subTaskWithCounter(ResourceString
.getResourceString("dialog.message.export.image.creating")
+ " : " + name);
viewer = createGraphicalViewer(display, diagram);
imageInfo = createImage(display, viewer, format, fileName, diagram,
category);
monitor.worked(1);
if (fileName != null) {
monitor.subTaskWithCounter(ResourceString
.getResourceString("dialog.message.export.image.output")
+ " : " + fileName);
writeToFile(imageInfo);
monitor.worked(1);
} else {
imageInfo.toImageData();
}
return imageInfo;
} finally {
if (imageInfo != null) {
imageInfo.dispose();
}
if (viewer != null && viewer.getContents() != null) {
viewer.getContents().deactivate();
}
}
}
示例7: extractDiagram
import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
protected static Object extractDiagram(GraphicalViewer viewer) {
final EditPart editPart = viewer.getContents();
editPart.refresh();
return editPart.getModel();
}