本文整理汇总了Java中org.eclipse.gef.editparts.LayerManager.getLayer方法的典型用法代码示例。如果您正苦于以下问题:Java LayerManager.getLayer方法的具体用法?Java LayerManager.getLayer怎么用?Java LayerManager.getLayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.gef.editparts.LayerManager
的用法示例。
在下文中一共展示了LayerManager.getLayer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: eraseTargetFeedback
import org.eclipse.gef.editparts.LayerManager; //导入方法依赖的package包/类
@Override
public void eraseTargetFeedback(final Request request) {
final LayerManager manager = (LayerManager) getHost().getRoot();
final IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER);
getFeedbackLayer().setBounds(layer.getBounds());
final List list = getFeedbackLayer().getChildren();
for (final Iterator iter = list.iterator(); iter.hasNext();) {
final Object obj = iter.next();
if (obj instanceof Label) {
iter.remove();
}
}
getFeedbackLayer().repaint();
super.eraseTargetFeedback(request);
}
示例2: eraseTargetFeedback
import org.eclipse.gef.editparts.LayerManager; //导入方法依赖的package包/类
@Override
public void eraseTargetFeedback(Request request) {
LayerManager manager = (LayerManager) this.getHost().getRoot();
IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER);
this.getFeedbackLayer().setBounds(layer.getBounds());
List list = this.getFeedbackLayer().getChildren();
for (Iterator iter = list.iterator(); iter.hasNext();) {
Object obj = iter.next();
if (obj instanceof Label) {
iter.remove();
}
}
this.getFeedbackLayer().repaint();
super.eraseTargetFeedback(request);
}
示例3: eraseTargetFeedback
import org.eclipse.gef.editparts.LayerManager; //导入方法依赖的package包/类
@Override
public void eraseTargetFeedback(Request request) {
final LayerManager manager = (LayerManager) getHost().getRoot();
final IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER);
getFeedbackLayer().setBounds(layer.getBounds());
final List<?> list = getFeedbackLayer().getChildren();
for (final Iterator<?> iter = list.iterator(); iter.hasNext();) {
final Object obj = iter.next();
if (obj instanceof Label) {
iter.remove();
}
}
getFeedbackLayer().repaint();
super.eraseTargetFeedback(request);
}
示例4: TimelineFeedbackManager
import org.eclipse.gef.editparts.LayerManager; //导入方法依赖的package包/类
public TimelineFeedbackManager(TimelineViewer timelineViewer, EPlan plan,
AbstractEditPolicy policy) {
this.timelineViewer = timelineViewer;
this.editPolicy = policy;
layerManager = (LayerManager)timelineViewer.getEditPartRegistry().get(LayerManager.ID);
feedbackLayerData = layerManager.getLayer(TimelineConstants.LAYER_FEEDBACK_DATA);
map = new HashMap<Rectangle, InvalidRangeRectangleFigure>();
planAdvisorMember = PlanAdvisorMember.get(plan);
timelineViewer.getControl().addDragDetectListener( this );
timelineViewer.getControl().addMouseListener( this );
}
示例5: getGuideLayer
import org.eclipse.gef.editparts.LayerManager; //导入方法依赖的package包/类
public IFigure getGuideLayer() {
LayerManager lm = (LayerManager) diagramViewer.getEditPartRegistry()
.get(LayerManager.ID);
if (lm != null)
return lm.getLayer(LayerConstants.GUIDE_LAYER);
return null;
}
示例6: ReportPrintGraphicalViewerOperation
import org.eclipse.gef.editparts.LayerManager; //导入方法依赖的package包/类
public ReportPrintGraphicalViewerOperation( GraphicalViewer g,
Drawable drawable, Device device, Rectangle region )
{
this.device = device;
this.region = region;
this.drawable = drawable;
this.viewer = g;
LayerManager lm = (LayerManager) viewer.getEditPartRegistry( )
.get( LayerManager.ID );
IFigure f = lm.getLayer( LayerConstants.PRINTABLE_LAYERS );
this.printSource = f;
}
示例7: getGuideLayer
import org.eclipse.gef.editparts.LayerManager; //导入方法依赖的package包/类
public IFigure getGuideLayer( )
{
LayerManager lm = (LayerManager) diagramViewer.getEditPartRegistry( )
.get( LayerManager.ID );
if ( lm != null )
return lm.getLayer( LayerConstants.GUIDE_LAYER );
return null;
}
示例8: getHandleLayer
import org.eclipse.gef.editparts.LayerManager; //导入方法依赖的package包/类
private IFigure getHandleLayer( )
{
super.getLayer( LayerConstants.HANDLE_LAYER );
LayerManager manager = (LayerManager) getViewer( ).getEditPartRegistry( )
.get( LayerManager.ID );
return manager.getLayer( LayerConstants.HANDLE_LAYER );
}
示例9: showMoveBendpointFeedback
import org.eclipse.gef.editparts.LayerManager; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void showMoveBendpointFeedback(final BendpointRequest bendpointrequest) {
final Relation relation = (Relation) getHost().getModel();
final RelationEditPart editPart = (RelationEditPart) getHost();
if (relation.getSource() == relation.getTarget()) {
if (bendpointrequest.getIndex() != 1) {
return;
}
final Point point = bendpointrequest.getLocation();
getConnection().translateToRelative(point);
final Bendpoint rate = getRate(point);
rate.setRelative(true);
final float rateX = (100f - (rate.getX() / 2)) / 100;
final float rateY = (100f - (rate.getY() / 2)) / 100;
final ERTableEditPart tableEditPart = (ERTableEditPart) editPart.getSource();
final Rectangle bounds = tableEditPart.getFigure().getBounds();
final Rectangle rect = new Rectangle();
rect.x = (int) (bounds.x + (bounds.width * rateX));
rect.y = (int) (bounds.y + (bounds.height * rateY));
rect.width = bounds.width * rate.getX() / 100;
rect.height = bounds.height * rate.getY() / 100;
relation.setSourceLocationp(100, (int) (100 * rateY));
relation.setTargetLocationp((int) (100 * rateX), 100);
final LayerManager manager = (LayerManager) tableEditPart.getRoot();
final IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER);
getFeedbackLayer().setBounds(layer.getBounds());
final List children = getFeedbackLayer().getChildren();
children.clear();
getFeedbackLayer().repaint();
final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager();
final double zoom = zoomManager.getZoom();
final Polyline feedbackFigure = new Polyline();
feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom)));
feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) ((rect.y + rect.height) * zoom)));
feedbackFigure.addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) ((rect.y + rect.height) * zoom)));
feedbackFigure.addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) (rect.y * zoom)));
feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom)));
feedbackFigure.setLineStyle(SWT.LINE_DASH);
feedbackFigure.translateToRelative(feedbackFigure.getLocation());
addFeedback(feedbackFigure);
} else {
super.showMoveBendpointFeedback(bendpointrequest);
}
}
示例10: showMoveBendpointFeedback
import org.eclipse.gef.editparts.LayerManager; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void showMoveBendpointFeedback(BendpointRequest bendpointrequest) {
Relation relation = (Relation) getHost().getModel();
RelationEditPart editPart = (RelationEditPart) this.getHost();
Category currentCategory = getDiagram().getCurrentCategory();
if (relation.getSource() == relation.getTarget()) {
if (bendpointrequest.getIndex() != 1) {
return;
}
Point point = bendpointrequest.getLocation();
this.getConnection().translateToRelative(point);
Bendpoint rate = this.getRate(point);
rate.setRelative(true);
float rateX = (100f - (rate.getX() / 2)) / 100;
float rateY = (100f - (rate.getY() / 2)) / 100;
ERTableEditPart tableEditPart = (ERTableEditPart) editPart
.getSource();
Rectangle bounds = tableEditPart.getFigure().getBounds();
Rectangle rect = new Rectangle();
rect.x = (int) (bounds.x + (bounds.width * rateX));
rect.y = (int) (bounds.y + (bounds.height * rateY));
rect.width = (int) (bounds.width * rate.getX() / 100);
rect.height = (int) (bounds.height * rate.getY() / 100);
relation.setSourceLocationp(currentCategory, 100, (int) (100 * rateY));
relation.setTargetLocationp(currentCategory, (int) (100 * rateX), 100);
LayerManager manager = (LayerManager) tableEditPart.getRoot();
IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER);
this.getFeedbackLayer().setBounds(layer.getBounds());
List children = this.getFeedbackLayer().getChildren();
children.clear();
this.getFeedbackLayer().repaint();
ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this
.getHost().getRoot()).getZoomManager();
double zoom = zoomManager.getZoom();
Polyline feedbackFigure = new Polyline();
feedbackFigure.addPoint(new Point((int) (rect.x * zoom),
(int) (rect.y * zoom)));
feedbackFigure.addPoint(new Point((int) (rect.x * zoom),
(int) ((rect.y + rect.height) * zoom)));
feedbackFigure.addPoint(new Point(
(int) ((rect.x + rect.width) * zoom),
(int) ((rect.y + rect.height) * zoom)));
feedbackFigure
.addPoint(new Point((int) ((rect.x + rect.width) * zoom),
(int) (rect.y * zoom)));
feedbackFigure.addPoint(new Point((int) (rect.x * zoom),
(int) (rect.y * zoom)));
feedbackFigure.setLineStyle(SWT.LINE_DASH);
feedbackFigure.translateToRelative(feedbackFigure.getLocation());
this.addFeedback(feedbackFigure);
} else {
super.showMoveBendpointFeedback(bendpointrequest);
}
}
示例11: saveEditorContentsAsImage
import org.eclipse.gef.editparts.LayerManager; //导入方法依赖的package包/类
private static void saveEditorContentsAsImage(IEditorPart editorPart,
GraphicalViewer viewer, String saveFilePath, int format) {
/*
* 1. First get the figure whose visuals we want to save as image. So we
* would like to save the rooteditpart which actually hosts all the
* printable layers.
*
* NOTE: ScalableRootEditPart manages layers and is registered
* graphicalviewer's editpartregistry with the key LayerManager.ID ...
* well that is because ScalableRootEditPart manages all layers that are
* hosted on a FigureCanvas. Many layers exist for doing different
* things
*/
Map editPartRegistry = viewer.getEditPartRegistry();
LayerManager rootEditPart = (LayerManager) editPartRegistry.get(LayerManager.ID);
IFigure rootFigure = rootEditPart.getLayer(LayerConstants.PRINTABLE_LAYERS);
for (Object obj : editPartRegistry.values()) {
if (obj instanceof ScreenEditPart){
rootFigure = ((ScreenEditPart)obj).getFigure();
break;
}
}
Rectangle rootFigureBounds = rootFigure.getBounds();
/*
* 2. Now we want to get the GC associated with the control on which all
* figures are painted by SWTGraphics. For that first get the SWT
* Control associated with the viewer on which the rooteditpart is set
* as contents
*/
Control figureCanvas = viewer.getControl();
GC figureCanvasGC = new GC(figureCanvas);
/*
* 3. Create a new Graphics for an Image onto which we want to paint
* rootFigure
*/
Image img = new Image(null, rootFigureBounds.width,
rootFigureBounds.height);
GC 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.setXORMode(figureCanvasGC.getXORMode());
Graphics imgGraphics = new SWTGraphics(imageGC);
/*
* 4. Draw rootFigure onto image. After that image will be ready for
* save
*/
rootFigure.paint(imgGraphics);
/* 5. Save image */
ImageData[] imgData = new ImageData[1];
imgData[0] = img.getImageData();
ImageLoader imgLoader = new ImageLoader();
imgLoader.data = imgData;
imgLoader.save(saveFilePath, format);
/* release OS resources */
figureCanvasGC.dispose();
imageGC.dispose();
img.dispose();
}
示例12: run
import org.eclipse.gef.editparts.LayerManager; //导入方法依赖的package包/类
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
if (getSelectedObjects().size() < 1)
return;
Object obj = getSelectedObjects().get(0);
if (!(obj instanceof EditPart))
return;
ScalableFreeformRootEditPart root = (ScalableFreeformRootEditPart) ((EditPart) obj).getRoot();
;
ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) root.getViewer();
FileDialog dlg = new FileDialog(viewer.getControl().getShell(), SWT.SAVE);
dlg.setFilterNames(new String[] { "JPEG Files (*.jpg)", "PNG Files (*.png)", "Bitmap Files (*.bmp)" });
dlg.setFilterExtensions(new String[] { "*.jpg", "*.png", "*.bmp" });
String fileName = dlg.open();
if (fileName == null)
return;
LayerManager lm = (LayerManager) viewer.getEditPartRegistry().get(LayerManager.ID);
IFigure figure = lm.getLayer(LayerConstants.PRINTABLE_LAYERS);
// IFigure backgroundfigure = lm.getLayer(LayerConstants.FEEDBACK_LAYER);
// Display display = getWorkbenchPart().getSite().getWorkbenchWindow().getWorkbench().getDisplay();
// Image img = new Image(display, figure.getSize().width, figure.getSize().height);
// GC gc = new GC(img);
// SWTGraphics graphics = new SWTGraphics(gc);
//
// figure.setLocation(new Point(0, 0));
// backgroundfigure.setLocation(new Point(0, 0));
// try {
// root.getZoomManager().setZoom(0.001);
// figure.paint(graphics);
// backgroundfigure.paint(graphics);
// } finally {
// root.getZoomManager().setZoom(1);
// figure.paint(graphics);
// gc.dispose();
// graphics.dispose();
// }
Diagram diagram = (Diagram) ((EditPart) obj).getModel();
DiagramImageUtil diagramUtil = new DiagramImageUtil(diagram);
Display.getDefault().syncExec(diagramUtil);
Image img = diagramUtil.getDiagramImage();
ImageLoader loader = new ImageLoader();
if (img == null) {
img = new Image(null, figure.getSize().width, figure.getSize().height);
}
loader.data = new ImageData[] { img.getImageData() };
if (fileName.toLowerCase().endsWith("jpg")) {
loader.save(fileName, SWT.IMAGE_JPEG);
} else if (fileName.toLowerCase().endsWith("png")) {
loader.save(fileName, SWT.IMAGE_PNG);
} else {
loader.save(fileName, SWT.IMAGE_BMP);
}
}
示例13: getGuideLayer
import org.eclipse.gef.editparts.LayerManager; //导入方法依赖的package包/类
public IFigure getGuideLayer() {
LayerManager lm = (LayerManager) diagramViewer.getEditPartRegistry().get(LayerManager.ID);
if (lm != null)
return lm.getLayer(LayerConstants.GUIDE_LAYER);
return null;
}
示例14: showMoveBendpointFeedback
import org.eclipse.gef.editparts.LayerManager; //导入方法依赖的package包/类
@Override
protected void showMoveBendpointFeedback(BendpointRequest bendpointrequest) {
final Relationship relation = (Relationship) getHost().getModel();
final RelationEditPart editPart = (RelationEditPart) getHost();
if (relation.getSourceWalker() == relation.getTargetWalker()) {
if (bendpointrequest.getIndex() != 1) {
return;
}
final Point point = bendpointrequest.getLocation();
getConnection().translateToRelative(point);
final Bendpoint rate = getRate(point);
rate.setRelative(true);
final float rateX = (100f - (rate.getX() / 2)) / 100;
final float rateY = (100f - (rate.getY() / 2)) / 100;
final ERTableEditPart tableEditPart = (ERTableEditPart) editPart.getSource();
final Rectangle bounds = tableEditPart.getFigure().getBounds();
final Rectangle rect = new Rectangle();
rect.x = (int) (bounds.x + (bounds.width * rateX));
rect.y = (int) (bounds.y + (bounds.height * rateY));
rect.width = (int) (bounds.width * rate.getX() / 100);
rect.height = (int) (bounds.height * rate.getY() / 100);
relation.setSourceLocationp(100, (int) (100 * rateY));
relation.setTargetLocationp((int) (100 * rateX), 100);
final LayerManager manager = (LayerManager) tableEditPart.getRoot();
final IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER);
getFeedbackLayer().setBounds(layer.getBounds());
final List<?> children = getFeedbackLayer().getChildren();
children.clear();
getFeedbackLayer().repaint();
final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager();
final double zoom = zoomManager.getZoom();
final Polyline feedbackFigure = new Polyline();
feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom)));
feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) ((rect.y + rect.height) * zoom)));
feedbackFigure.addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) ((rect.y + rect.height) * zoom)));
feedbackFigure.addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) (rect.y * zoom)));
feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom)));
feedbackFigure.setLineStyle(SWT.LINE_DASH);
feedbackFigure.translateToRelative(feedbackFigure.getLocation());
addFeedback(feedbackFigure);
} else {
super.showMoveBendpointFeedback(bendpointrequest);
}
}
示例15: showMoveBendpointFeedback
import org.eclipse.gef.editparts.LayerManager; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void showMoveBendpointFeedback(BendpointRequest bendpointrequest) {
Relation relation = (Relation) getHost().getModel();
RelationEditPart editPart = (RelationEditPart) this.getHost();
if (relation.getSource() == relation.getTarget()) {
if (bendpointrequest.getIndex() != 1) {
return;
}
Point point = bendpointrequest.getLocation();
this.getConnection().translateToRelative(point);
Bendpoint rate = this.getRate(point);
rate.setRelative(true);
float rateX = (100f - (rate.getX() / 2)) / 100;
float rateY = (100f - (rate.getY() / 2)) / 100;
ERTableEditPart tableEditPart = (ERTableEditPart) editPart
.getSource();
Rectangle bounds = tableEditPart.getFigure().getBounds();
Rectangle rect = new Rectangle();
rect.x = (int) (bounds.x + (bounds.width * rateX));
rect.y = (int) (bounds.y + (bounds.height * rateY));
rect.width = (int) (bounds.width * rate.getX() / 100);
rect.height = (int) (bounds.height * rate.getY() / 100);
relation.setSourceLocationp(100, (int) (100 * rateY));
relation.setTargetLocationp((int) (100 * rateX), 100);
LayerManager manager = (LayerManager) tableEditPart.getRoot();
IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER);
this.getFeedbackLayer().setBounds(layer.getBounds());
List children = this.getFeedbackLayer().getChildren();
children.clear();
this.getFeedbackLayer().repaint();
ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this
.getHost().getRoot()).getZoomManager();
double zoom = zoomManager.getZoom();
Polyline feedbackFigure = new Polyline();
feedbackFigure.addPoint(new Point((int) (rect.x * zoom),
(int) (rect.y * zoom)));
feedbackFigure.addPoint(new Point((int) (rect.x * zoom),
(int) ((rect.y + rect.height) * zoom)));
feedbackFigure.addPoint(new Point(
(int) ((rect.x + rect.width) * zoom),
(int) ((rect.y + rect.height) * zoom)));
feedbackFigure
.addPoint(new Point((int) ((rect.x + rect.width) * zoom),
(int) (rect.y * zoom)));
feedbackFigure.addPoint(new Point((int) (rect.x * zoom),
(int) (rect.y * zoom)));
feedbackFigure.setLineStyle(SWT.LINE_DASH);
feedbackFigure.translateToRelative(feedbackFigure.getLocation());
this.addFeedback(feedbackFigure);
} else {
super.showMoveBendpointFeedback(bendpointrequest);
}
}