org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil Java Examples
The following examples show how to use
org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XtextDirectEditManager.java From statecharts with Eclipse Public License 1.0 | 6 votes |
/** * Given a label figure object, this will calculate the correct Font needed * to display into screen coordinates, taking into account the current * mapmode. This will typically be used by direct edit cell editors that * need to display independent of the zoom or any coordinate mapping that is * taking place on the drawing surface. * * @param label * the label to use for the font calculation * @return the <code>Font</code> that is scaled to the screen coordinates. * Note: the returned <code>Font</code> should not be disposed since * it is cached by a common resource manager. */ protected Font getScaledFont(IFigure label) { Font scaledFont = label.getFont(); FontData data = scaledFont.getFontData()[0]; Dimension fontSize = new Dimension(0, MapModeUtil.getMapMode(label).DPtoLP(data.getHeight())); label.translateToAbsolute(fontSize); if (Math.abs(data.getHeight() - fontSize.height) < 2) fontSize.height = data.getHeight(); try { FontDescriptor fontDescriptor = FontDescriptor.createFrom(data); cachedFontDescriptors.add(fontDescriptor); return getResourceManager().createFont(fontDescriptor); } catch (DeviceResourceException e) { Trace.catching(DiagramUIPlugin.getInstance(), DiagramUIDebugOptions.EXCEPTIONS_CATCHING, getClass(), "getScaledFont", e); //$NON-NLS-1$ Log.error(DiagramUIPlugin.getInstance(), DiagramUIStatusCodes.IGNORED_EXCEPTION_WARNING, "getScaledFont", e); //$NON-NLS-1$ } return JFaceResources.getDefaultFont(); }
Example #2
Source File: SyntaxColoringLabel.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@Override public FlowUtilitiesEx getFlowUtilities() { if (flowUtilities == null) { flowUtilities = new FlowUtilitiesEx(MapModeUtil.getMapMode(this)) { @Override protected TextUtilities getTextUtilities() { if (textUtilities == null) { textUtilities = new StyleTextUtilities(MapModeUtil.getMapMode(StyledTextFlow.this)); } return textUtilities; } }; } return flowUtilities; }
Example #3
Source File: TransitionPriorityDecorationProvider.java From statecharts with Eclipse Public License 1.0 | 5 votes |
public void createDecorators(IGraphicalEditPart editPart) { PriorityFigure figure = new PriorityFigure(MapModeUtil.getMapMode(), getPriority(editPart)); figure.setSize(12, 13); setDecoration(getDecoratorTarget().addDecoration(figure, new ConnectionLocator((Connection) editPart.getFigure(), ConnectionLocator.TARGET) { protected Point getLocation(PointList points) { Point p = PointListUtilities.pointOn(PointListUtilities.copyPoints(points), DISTANCE_TO_SOURCE, KeyPoint.ORIGIN, new Point()); return p; } }, false)); figure.setToolTip(new Label("Transition Priority " + getPriority(editPart))); }
Example #4
Source File: FeedbackGraphicalNodeEditPolicy.java From statecharts with Eclipse Public License 1.0 | 5 votes |
protected IMapMode getMapMode() { RootEditPart root = getHost().getRoot(); if (root instanceof DiagramRootEditPart) { DiagramRootEditPart dgrmRoot = (DiagramRootEditPart) root; return dgrmRoot.getMapMode(); } return MapModeUtil.getMapMode(); }
Example #5
Source File: RegionPriorityDecorationProvider.java From statecharts with Eclipse Public License 1.0 | 4 votes |
public void createDecorators(IGraphicalEditPart editPart) { PriorityFigure figure = new PriorityFigure(MapModeUtil.getMapMode(), getPriority(editPart)); figure.setSize(10, 10); setDecoration( getDecoratorTarget().addShapeDecoration(figure, IDecoratorTarget.Direction.NORTH_WEST, -1, false)); }