Java Code Examples for org.eclipse.draw2d.IFigure#setForegroundColor()

The following examples show how to use org.eclipse.draw2d.IFigure#setForegroundColor() . 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: HighlightingSupportAdapter.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
public void highlight(List<? extends EObject> semanticElements, HighlightingParameters parameters) {
	synchronized (semanticElements) {
		for (EObject semanticElement : semanticElements) {
			IGraphicalEditPart editPartForSemanticElement = getEditPartForSemanticElement(semanticElement);
			if (editPartForSemanticElement != null) {
				IFigure figure = getTargetFigure(editPartForSemanticElement);
				if (parameters != null) {
					figure.setForegroundColor(parameters.foregroundFadingColor);
					figure.setBackgroundColor(parameters.backgroundFadingColor);
					figure.invalidate();
				} else {
					flashingFigures.clear();
					ColorMemento memento = figureStates.get(figure);
					if (memento != null)
						memento.restore();
				}
			}
		}
	}
}
 
Example 2
Source File: TimelineViewer.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void update(Object element, String[] properties) {
	final IFigure figure = fElementToFigureMap.get(element);
	if (figure != null) {

		if (isCursorElement(element))
			getControl().getRootFigure().updateCursorFigure(figure, toCursor(element));

		else if (isTrackElement(element))
			getControl().getRootFigure().updateTrackFigure(figure, getLabelProvider().getText(element));

		else if (isEventElement(element))
			getControl().getRootFigure().updateEventFigure(figure, toEvent(element));

		else if (isLaneElement(element)) {
			if (getLabelProvider() instanceof IColorProvider) {
				// color update for all elements
				Color foreground = ((IColorProvider) getLabelProvider()).getForeground(element);
				if (foreground == null)
					foreground = getStyleProvider().getLaneColor();

				figure.setForegroundColor(foreground);

				internalRefresh(element);
			}
		}
	}
}
 
Example 3
Source File: FigureController.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void applyColor ( final IFigure figure, final Color color )
{
    figure.setForegroundColor ( color );
}
 
Example 4
Source File: ERDiagramEditor.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private void initViewerAction(final GraphicalViewer viewer) {
    final ScalableFreeformRootEditPart rootEditPart = new PagableFreeformRootEditPart(diagram);
    viewer.setRootEditPart(rootEditPart);

    final ZoomManager manager = rootEditPart.getZoomManager();

    final double[] zoomLevels = new double[] {0.1, 0.25, 0.5, 0.75, 0.8, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 10.0, 20.0};
    manager.setZoomLevels(zoomLevels);

    final List<String> zoomContributions = new ArrayList<String>();
    zoomContributions.add(ZoomManager.FIT_ALL);
    zoomContributions.add(ZoomManager.FIT_HEIGHT);
    zoomContributions.add(ZoomManager.FIT_WIDTH);
    manager.setZoomLevelContributions(zoomContributions);

    final ZoomInAction zoomInAction = new ZoomInAction(manager);
    final ZoomOutAction zoomOutAction = new ZoomOutAction(manager);
    final ZoomAdjustAction zoomAdjustAction = new ZoomAdjustAction(manager);

    getActionRegistry().registerAction(zoomInAction);
    getActionRegistry().registerAction(zoomOutAction);
    getActionRegistry().registerAction(zoomAdjustAction);

    addKeyHandler(zoomInAction);
    addKeyHandler(zoomOutAction);

    final IFigure gridLayer = rootEditPart.getLayer(LayerConstants.GRID_LAYER);
    gridLayer.setForegroundColor(Resources.GRID_COLOR);

    IAction action = new ToggleGridAction(viewer);
    getActionRegistry().registerAction(action);

    action = new ToggleSnapToGeometryAction(viewer);
    getActionRegistry().registerAction(action);

    action = new ChangeBackgroundColorAction(this, diagram);
    getActionRegistry().registerAction(action);
    getSelectionActions().add(action.getId());

    action = new TooltipAction(this);
    getActionRegistry().registerAction(action);

    action = new LockEditAction(this);
    getActionRegistry().registerAction(action);

    action = new ExportToDBAction(this);
    getActionRegistry().registerAction(action);

    actionBarContributor = new ERDiagramActionBarContributor();
    actionBarContributor.init(getEditorSite().getActionBars(), getSite().getPage());
    // action = new ToggleRulerVisibilityAction(viewer);
    // this.getActionRegistry().registerAction(action);
}
 
Example 5
Source File: MainDiagramEditor.java    From erflute with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
protected void initViewerAction(GraphicalViewer viewer) {
    final ScalableFreeformRootEditPart rootEditPart = new PagableFreeformRootEditPart(diagram);
    viewer.setRootEditPart(rootEditPart);

    final ZoomManager manager = rootEditPart.getZoomManager();

    final double[] zoomLevels = new double[] { 0.1, 0.25, 0.5, 0.75, 0.8, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 10.0, 20.0 };
    manager.setZoomLevels(zoomLevels);

    final List<String> zoomContributions = new ArrayList<>();
    zoomContributions.add(ZoomManager.FIT_ALL);
    zoomContributions.add(ZoomManager.FIT_HEIGHT);
    zoomContributions.add(ZoomManager.FIT_WIDTH);
    manager.setZoomLevelContributions(zoomContributions);

    final ZoomInAction zoomInAction = new ZoomInAction(manager);
    final ZoomOutAction zoomOutAction = new ZoomOutAction(manager);
    final ZoomAdjustAction zoomAdjustAction = new ZoomAdjustAction(manager);

    getActionRegistry().registerAction(zoomInAction);
    getActionRegistry().registerAction(zoomOutAction);
    getActionRegistry().registerAction(zoomAdjustAction);

    addKeyHandler(zoomInAction);
    addKeyHandler(zoomOutAction);

    final IFigure gridLayer = rootEditPart.getLayer(LayerConstants.GRID_LAYER);
    gridLayer.setForegroundColor(DesignResources.GRID_COLOR);

    IAction action = new ToggleGridAction(viewer);
    getActionRegistry().registerAction(action);

    action = new ChangeBackgroundColorAction(this, diagram);
    getActionRegistry().registerAction(action);
    getSelectionActions().add(action.getId());

    action = new ToggleMainColumnAction(this);
    getActionRegistry().registerAction(action);

    action = new LockEditAction(this);
    getActionRegistry().registerAction(action);

    action = new ExportToDBAction(this);
    getActionRegistry().registerAction(action);

    this.actionBarContributor = new ERDiagramActionBarContributor(zoomComboContributionItem);
}
 
Example 6
Source File: ERDiagramEditor.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
protected void initViewerAction(GraphicalViewer viewer) {
	ScalableFreeformRootEditPart rootEditPart = new PagableFreeformRootEditPart(
			this.diagram);
	viewer.setRootEditPart(rootEditPart);

	ZoomManager manager = rootEditPart.getZoomManager();

	double[] zoomLevels = new double[] { 0.1, 0.25, 0.5, 0.75, 0.8, 1.0,
			1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 10.0, 20.0 };
	manager.setZoomLevels(zoomLevels);

	List<String> zoomContributions = new ArrayList<String>();
	zoomContributions.add(ZoomManager.FIT_ALL);
	zoomContributions.add(ZoomManager.FIT_HEIGHT);
	zoomContributions.add(ZoomManager.FIT_WIDTH);
	manager.setZoomLevelContributions(zoomContributions);

	ZoomInAction zoomInAction = new ZoomInAction(manager);
	ZoomOutAction zoomOutAction = new ZoomOutAction(manager);
	ZoomAdjustAction zoomAdjustAction = new ZoomAdjustAction(manager);

	this.getActionRegistry().registerAction(zoomInAction);
	this.getActionRegistry().registerAction(zoomOutAction);
	this.getActionRegistry().registerAction(zoomAdjustAction);

	this.addKeyHandler(zoomInAction);
	this.addKeyHandler(zoomOutAction);

	IFigure gridLayer = rootEditPart.getLayer(LayerConstants.GRID_LAYER);
	gridLayer.setForegroundColor(Resources.GRID_COLOR);

	IAction action = new ToggleGridAction(viewer);
	this.getActionRegistry().registerAction(action);

	action = new ChangeBackgroundColorAction(this, this.diagram);
	this.getActionRegistry().registerAction(action);
	this.getSelectionActions().add(action.getId());

	action = new EditExcelAction(this, this.diagram);
	this.getActionRegistry().registerAction(action);
	this.getSelectionActions().add(action.getId());

	action = new ToggleMainColumnAction(this);
	this.getActionRegistry().registerAction(action);

	action = new LockEditAction(this);
	this.getActionRegistry().registerAction(action);

	action = new ExportToDBAction(this);
	this.getActionRegistry().registerAction(action);

	this.actionBarContributor = new ERDiagramActionBarContributor(
			this.zoomComboContributionItem);

	// action = new ToggleRulerVisibilityAction(viewer);
	// this.getActionRegistry().registerAction(action);
	//
	// action = new ToggleSnapToGeometryAction(viewer);
	// this.getActionRegistry().registerAction(action);
}