List of usage examples for org.eclipse.jface.preference ColorSelector getColorValue
public RGB getColorValue()
From source file:cc.warlock.rcp.stormfront.ui.prefs.PresetsPreferencePage.java
License:Open Source License
private RGB getColor(ColorSelector selector) { return selector.getColorValue() == null ? mainBGSelector.getColorValue() : selector.getColorValue(); }
From source file:com.astra.ses.spell.gui.preferences.ui.pages.GUIColorsPreferencePage.java
License:Open Source License
@Override public void performApply() { IConfigurationManager conf = getConfigurationManager(); for (GuiColorKey key : GuiColorKey.values()) { ColorSelector selector = m_colorSelectors[key.ordinal()]; RGB rgb = selector.getColorValue(); conf.setGuiColor(key, rgb);/*from w ww. ja v a 2s .c om*/ } }
From source file:com.astra.ses.spell.gui.preferences.ui.pages.ProcedureColorsPreferencePage.java
License:Open Source License
@Override public void performApply() { IConfigurationManager conf = getConfigurationManager(); for (ExecutorStatus key : ExecutorStatus.values()) { ColorSelector selector = m_colorSelectors[key.ordinal()]; RGB rgb = selector.getColorValue(); conf.setColor(ProcColorKey.getPreferenceName(key), rgb); }//from w ww. j ava2 s. c om }
From source file:com.astra.ses.spell.gui.preferences.ui.pages.StatusColorsPreferencePage.java
License:Open Source License
@Override public void performApply() { IConfigurationManager conf = getConfigurationManager(); for (StatusColorKey key : StatusColorKey.values()) { ColorSelector selector = m_colorSelectors[key.ordinal()]; RGB rgb = selector.getColorValue(); conf.setColor(key.getPreferenceName(), rgb); }/*from ww w. j ava 2 s .co m*/ }
From source file:com.siteview.mde.internal.ui.preferences.SyntaxColorTab.java
License:Open Source License
private void createElementTable(Composite parent) { Composite container = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(2, true); layout.marginWidth = layout.marginHeight = 0; container.setLayout(layout);//from w w w .j av a 2s . c o m container.setLayoutData(new GridData(GridData.FILL_BOTH)); Label label = new Label(container, SWT.LEFT); label.setText(MDEUIMessages.SyntaxColorTab_elements); GridData gd = new GridData(); gd.horizontalSpan = 2; label.setLayoutData(gd); fElementViewer = new TableViewer(container, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER); fElementViewer.setLabelProvider(new LabelProvider()); fElementViewer.setContentProvider(ArrayContentProvider.getInstance()); fElementViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); Composite colorComposite = new Composite(container, SWT.NONE); colorComposite.setLayout(new GridLayout(2, false)); colorComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); label = new Label(colorComposite, SWT.LEFT); label.setText(MDEUIMessages.SyntaxColorTab_color); final ColorSelector colorSelector = new ColorSelector(colorComposite); Button colorButton = colorSelector.getButton(); colorButton.setLayoutData(new GridData(GridData.BEGINNING)); colorButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { ColorElement item = getColorElement(fElementViewer); item.setColorValue(colorSelector.getColorValue()); } }); fBoldButton = new Button(colorComposite, SWT.CHECK); gd = new GridData(); gd.horizontalSpan = 2; fBoldButton.setLayoutData(gd); fBoldButton.setText(MDEUIMessages.SyntaxColorTab_bold); fBoldButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { ColorElement item = getColorElement(fElementViewer); item.setBold(fBoldButton.getSelection()); } }); fItalicButton = new Button(colorComposite, SWT.CHECK); gd = new GridData(); gd.horizontalSpan = 2; fItalicButton.setLayoutData(gd); fItalicButton.setText(MDEUIMessages.SyntaxColorTab_italic); fItalicButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { ColorElement item = getColorElement(fElementViewer); item.setItalic(fItalicButton.getSelection()); } }); fElementViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { ColorElement item = getColorElement(fElementViewer); colorSelector.setColorValue(item.getColorValue()); fBoldButton.setSelection(item.isBold()); fItalicButton.setSelection(item.isItalic()); } }); fElementViewer.setInput(getColorData()); fElementViewer.setComparator(new ViewerComparator()); fElementViewer.setSelection(new StructuredSelection(fElementViewer.getElementAt(0))); }
From source file:de.byteholder.geoclipse.mapprovider.DialogMPProfile.java
License:Open Source License
/** * @param colorSelector//from w w w . j a v a2 s .co m * @return Returns the color value of the {@link ColorSelector} or -1 when the color is black */ private int getColorValue(final ColorSelector colorSelector) { final RGB rgb = colorSelector.getColorValue(); colorSelector.getButton().setToolTipText(rgb.toString()); final int colorValue = ((rgb.red & 0xFF) << 0) | ((rgb.green & 0xFF) << 8) | ((rgb.blue & 0xFF) << 16); return colorValue == 0 ? -1 : colorValue; }
From source file:eu.hydrologis.jgrass.annotationlayer.AnnotationsPropertiesView.java
License:Open Source License
public void createPartControl(Composite parent) { Composite propsComposite = new Composite(parent, SWT.None); propsComposite.setLayout(new RowLayout()); propsComposite.setLayoutData(/*ww w . j a v a2 s . c o m*/ new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL)); // stroke width Image img1 = AbstractUIPlugin .imageDescriptorFromPlugin(BeegisUtilsPlugin.PLUGIN_ID, "/icons/strokewidth_1.png").createImage(); Image img2 = AbstractUIPlugin .imageDescriptorFromPlugin(BeegisUtilsPlugin.PLUGIN_ID, "/icons/strokewidth_2.png").createImage(); Image img3 = AbstractUIPlugin .imageDescriptorFromPlugin(BeegisUtilsPlugin.PLUGIN_ID, "/icons/strokewidth_3.png").createImage(); Image img4 = AbstractUIPlugin .imageDescriptorFromPlugin(BeegisUtilsPlugin.PLUGIN_ID, "/icons/strokewidth_4.png").createImage(); Image img5 = AbstractUIPlugin .imageDescriptorFromPlugin(BeegisUtilsPlugin.PLUGIN_ID, "/icons/strokewidth_5.png").createImage(); Composite strokeComposite = new Composite(propsComposite, SWT.None); strokeComposite.setLayout(new GridLayout(2, false)); final ImageCombo strokeWidthCombo = new ImageCombo(strokeComposite, SWT.READ_ONLY); GridData gridDataWidth = new GridData(SWT.FILL, SWT.FILL, true, true); gridDataWidth.widthHint = 30; strokeWidthCombo.setLayoutData(gridDataWidth); strokeWidthCombo.add("1", img1); strokeWidthCombo.add("2", img2); strokeWidthCombo.add("3", img3); strokeWidthCombo.add("4", img4); strokeWidthCombo.add("5", img5); strokeWidthCombo.select(0); strokeWidthCombo.setToolTipText("stroke width"); strokeWidthCombo.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int selectedIndex = strokeWidthCombo.getSelectionIndex(); int strokeWidth = STROKES[selectedIndex]; AnnotationPlugin.getDefault().setCurrentStrokeWidth(strokeWidth); double scale = ApplicationGIS.getActiveMap().getViewportModel().getScaleDenominator(); AnnotationPlugin.getDefault().setCurrentScale(scale); } }); // alpha final Combo alphaCombo = new Combo(strokeComposite, SWT.DROP_DOWN | SWT.READ_ONLY); GridData gridData2 = new GridData(SWT.FILL, SWT.FILL, true, true); alphaCombo.setLayoutData(gridData2); String[] items = new String[ALPHAS.length]; for (int i = 0; i < items.length; i++) { items[i] = ALPHAS[i] + "%"; } alphaCombo.setItems(items); alphaCombo.select(ALPHAS.length - 1); alphaCombo.setToolTipText("stroke alpha"); alphaCombo.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int selectedIndex = alphaCombo.getSelectionIndex(); int alphaInPercent = ALPHAS[selectedIndex]; int strokeAlpha = 255 * alphaInPercent / 100; Color c = AnnotationPlugin.getDefault().getCurrentStrokeColor(); AnnotationPlugin.getDefault() .setCurrentStrokeColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), strokeAlpha)); } }); // color // final Label strokeColLabel = new Label(propsComposite, SWT.NONE); // strokeColLabel.setText("Stroke color"); final ColorSelector cs = new ColorSelector(propsComposite); RowData rd1 = new RowData(); rd1.height = 30; rd1.width = 50; cs.getButton().setLayoutData(rd1); // new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); int[] cc = AnnotationPlugin.getDefault().getCurrentStrokeColorInt(); cs.setColorValue(new RGB(cc[0], cc[1], cc[2])); cs.getButton().setToolTipText("stroke color"); cs.getButton().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { RGB rgb = cs.getColorValue(); int alpha = AnnotationPlugin.getDefault().getCurrentStrokeColorInt()[3]; AnnotationPlugin.getDefault().setCurrentStrokeColor(new Color(rgb.red, rgb.green, rgb.blue, alpha)); } }); // clear all ImageDescriptor clearID = AbstractUIPlugin.imageDescriptorFromPlugin(AnnotationPlugin.PLUGIN_ID, "icons/trash.gif"); //$NON-NLS-1$ final Button clearButton = new Button(propsComposite, SWT.PUSH); // GridData gd1 = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); // clearButton.setLayoutData(gd1); RowData rd2 = new RowData(); rd2.height = 30; rd2.width = 50; clearButton.setLayoutData(rd2); clearButton.setImage(clearID.createImage()); clearButton.setToolTipText("clear the area from all drawings"); clearButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { boolean answer = MessageDialog.openQuestion(clearButton.getShell(), "Removal warning", "Do you really want to remove all annotations?"); if (!answer) { return; } AnnotationPlugin.getDefault().getStrokes().clear(); JGrassCatalogUtilities.getMapgraphicLayerByClass(AnnotationLayerMapGraphic.class).refresh(null); } }); // clear last ImageDescriptor clearLast = AbstractUIPlugin.imageDescriptorFromPlugin(AnnotationPlugin.PLUGIN_ID, "icons/trashlast.gif"); //$NON-NLS-1$ Button clearLastButton = new Button(propsComposite, SWT.PUSH); RowData rd3 = new RowData(); rd3.height = 30; rd3.width = 50; clearLastButton.setLayoutData(rd3); // GridData gd2 = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); // clearLastButton.setLayoutData(gd2); clearLastButton.setImage(clearLast.createImage()); clearLastButton.setToolTipText("remove last stroke from annotations layer"); clearLastButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { List<DressedWorldStroke> strokes = AnnotationPlugin.getDefault().getStrokes(); int size = strokes.size(); if (size < 1) return; strokes.remove(size - 1); JGrassCatalogUtilities.getMapgraphicLayerByClass(AnnotationLayerMapGraphic.class).refresh(null); } }); }
From source file:eu.hydrologis.jgrass.ui.utilities.editors.SimpleSWTImageEditor.java
License:Open Source License
/** * Constructor for the image editor.//from w w w . j a v a 2 s . c o m * * @param parent the parent composite. * @param style the swt style for the component. * @param preloadedLines a list of lines to be drawn. * @param backGroundImage a background image to use in the canvas. * @param minScroll the minimum dimension for the scrolling. * @param doZoom flag that defines if the zoom tools should be added. */ public SimpleSWTImageEditor(Composite parent, int style, List<DressedStroke> preloadedLines, Image backGroundImage, Point minScroll, boolean doZoom) { this.doZoom = doZoom; if (backGroundImage != null) this.backImage = backGroundImage; if (preloadedLines == null) { this.lines = new ArrayList<DressedStroke>(); } else { this.lines = preloadedLines; } mainComposite = new Composite(parent, style); mainComposite.setLayout(new GridLayout()); propsComposite = new Composite(mainComposite, style); propsComposite.setLayout(new RowLayout()); propsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); // stroke width Image img1 = AbstractUIPlugin .imageDescriptorFromPlugin(UiUtilitiesPlugin.PLUGIN_ID, "/icons/strokewidth_1.png").createImage(); Image img2 = AbstractUIPlugin .imageDescriptorFromPlugin(UiUtilitiesPlugin.PLUGIN_ID, "/icons/strokewidth_2.png").createImage(); Image img3 = AbstractUIPlugin .imageDescriptorFromPlugin(UiUtilitiesPlugin.PLUGIN_ID, "/icons/strokewidth_3.png").createImage(); Image img4 = AbstractUIPlugin .imageDescriptorFromPlugin(UiUtilitiesPlugin.PLUGIN_ID, "/icons/strokewidth_4.png").createImage(); Image img5 = AbstractUIPlugin .imageDescriptorFromPlugin(UiUtilitiesPlugin.PLUGIN_ID, "/icons/strokewidth_5.png").createImage(); Composite strokeComposite = new Composite(propsComposite, SWT.None); strokeComposite.setLayout(new GridLayout(2, false)); final ImageCombo strokeWidthCombo = new ImageCombo(strokeComposite, SWT.READ_ONLY); GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); gridData.widthHint = 30; strokeWidthCombo.setLayoutData(gridData); strokeWidthCombo.add("1", img1); strokeWidthCombo.add("2", img2); strokeWidthCombo.add("3", img3); strokeWidthCombo.add("4", img4); strokeWidthCombo.add("5", img5); strokeWidthCombo.select(0); strokeWidthCombo.setToolTipText("stroke width"); strokeWidthCombo.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int selectedIndex = strokeWidthCombo.getSelectionIndex(); strokeWidth[0] = STROKES[selectedIndex]; } }); // alpha final Combo alphaCombo = new Combo(strokeComposite, SWT.DROP_DOWN | SWT.READ_ONLY); GridData gridData2 = new GridData(SWT.FILL, SWT.FILL, true, true); alphaCombo.setLayoutData(gridData2); String[] items = new String[ALPHAS.length]; for (int i = 0; i < items.length; i++) { items[i] = ALPHAS[i] + "%"; } alphaCombo.setItems(items); alphaCombo.select(ALPHAS.length - 1); alphaCombo.setToolTipText("stroke alpha"); alphaCombo.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int selectedIndex = alphaCombo.getSelectionIndex(); int alphaInPercent = ALPHAS[selectedIndex]; strokeAlpha = 255 * alphaInPercent / 100; } }); Composite buttonsComposite = new Composite(propsComposite, SWT.NONE); if (doZoom) { buttonsComposite.setLayout(new GridLayout(6, false)); } else { buttonsComposite.setLayout(new GridLayout(3, false)); } // color final ColorSelector cs = new ColorSelector(buttonsComposite); Button csButton = cs.getButton(); GridData gridData3 = new GridData(SWT.FILL, SWT.FILL, true, true); gridData3.widthHint = 25; csButton.setLayoutData(gridData3); cs.setColorValue(new RGB(strokeRGB[0], strokeRGB[1], strokeRGB[2])); cs.getButton().setToolTipText("stroke color"); cs.getButton().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { RGB rgb = cs.getColorValue(); strokeRGB = new int[] { rgb.red, rgb.green, rgb.blue }; } }); // clear all ImageDescriptor clearID = AbstractUIPlugin.imageDescriptorFromPlugin(UiUtilitiesPlugin.PLUGIN_ID, "icons/trash.gif"); //$NON-NLS-1$ Button clearButton = new Button(buttonsComposite, SWT.BORDER | SWT.PUSH); clearButton.setImage(clearID.createImage()); clearButton.setToolTipText("clear the area from drawings"); clearButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { lines.removeAll(lines); drawArea.redraw(); } }); // clear shape ImageDescriptor removeID = AbstractUIPlugin.imageDescriptorFromPlugin(UiUtilitiesPlugin.PLUGIN_ID, "icons/close.gif"); //$NON-NLS-1$ Button removeButton = new Button(buttonsComposite, SWT.BORDER | SWT.PUSH); removeButton.setImage(removeID.createImage()); removeButton.setToolTipText("remove selected line"); removeButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { isRemoveMode = true; final Cursor cursor = new Cursor(drawArea.getDisplay(), SWT.CURSOR_CROSS); drawArea.setCursor(cursor); } }); if (doZoom) { // zoom all ImageDescriptor zoomAllID = AbstractUIPlugin.imageDescriptorFromPlugin(UiUtilitiesPlugin.PLUGIN_ID, "icons/zoom_all.gif"); //$NON-NLS-1$ Button zoomAllButton = new Button(buttonsComposite, SWT.PUSH); zoomAllButton.setImage(zoomAllID.createImage()); zoomAllButton.setToolTipText("zoom to the whole extend"); zoomAllButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { calculateBaseScaleFactor(); scaleFactor = baseScaleFactor; drawArea.redraw(); } }); // zoom in ImageDescriptor zoomInID = AbstractUIPlugin.imageDescriptorFromPlugin(UiUtilitiesPlugin.PLUGIN_ID, "icons/zoom_in.gif"); //$NON-NLS-1$ Button zoomInButton = new Button(buttonsComposite, SWT.PUSH); zoomInButton.setImage(zoomInID.createImage()); zoomInButton.setToolTipText("zoom in"); zoomInButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { scaleFactor = scaleFactor * 1.2; drawArea.redraw(); } }); // zoom out ImageDescriptor zoomOutID = AbstractUIPlugin.imageDescriptorFromPlugin(UiUtilitiesPlugin.PLUGIN_ID, "icons/zoom_out.gif"); //$NON-NLS-1$ Button zoomOutButton = new Button(buttonsComposite, SWT.PUSH); zoomOutButton.setImage(zoomOutID.createImage()); zoomOutButton.setToolTipText("zoom out"); zoomOutButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { scaleFactor = scaleFactor / 1.2; drawArea.redraw(); } }); } drawAreaScroller = new ScrolledComposite(mainComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); drawArea = new Canvas(drawAreaScroller, SWT.None); defaultCursor = drawArea.getCursor(); drawAreaScroller.setContent(drawArea); drawAreaScroller.setExpandHorizontal(true); drawAreaScroller.setExpandVertical(true); if (minScroll != null) { drawAreaScroller.setMinWidth(minScroll.x); drawAreaScroller.setMinHeight(minScroll.y); } drawAreaScroller.setLayoutData( new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL)); Listener drawListener = new Listener() { int lastX = 0, lastY = 0; List<Integer> line = null; GC gc = null; public void handleEvent(Event event) { /* * REMOVE MODE */ if (isRemoveMode && event.type == SWT.MouseDown) { for (int i = 0; i < lines.size(); i++) { DressedStroke stroke = lines.get(i); int x = event.x; int y = event.y; int[] nodes = stroke.getScaledNodes(baseScaleFactor); for (int j = 0; j < nodes.length - 1; j = j + 2) { Point2f linePoint = new Point2f(nodes[j], nodes[j + 1]); Point2f clickPoint = new Point2f(x, y); int threshold = stroke.strokeWidth[0]; threshold = (int) Math.round((double) threshold * baseScaleFactor); threshold = threshold < 10 ? 10 : threshold; if (clickPoint.distance(linePoint) < threshold) { lines.remove(i); isRemoveMode = false; drawArea.setCursor(defaultCursor); drawArea.redraw(); return; } } } } if (isRemoveMode && (event.type == SWT.MouseMove || event.type == SWT.MouseUp)) { return; } /* * DRAWING MODE */ if (scaleFactor == -1) { calculateBaseScaleFactor(); scaleFactor = baseScaleFactor; } switch (event.type) { case SWT.Paint: if (drawnImage != null) drawnImage.dispose(); drawnImage = new Image(drawArea.getDisplay(), drawArea.getBounds()); GC gcImage = new GC(drawnImage); // draw the background image if (backImage != null) { Rectangle imgBounds = backImage.getBounds(); ImageData newImageData = backImage.getImageData().scaledTo( (int) Math.round(imgBounds.width * scaleFactor), (int) Math.round(imgBounds.height * scaleFactor)); Image newImage = new Image(drawArea.getDisplay(), newImageData); gcImage.drawImage(newImage, 0, 0); } // draw the lines for (int i = 0; i < lines.size(); i = i + 1) { DressedStroke tmpStroke = lines.get(i); gcImage.setLineWidth((int) Math.round(tmpStroke.strokeWidth[0] * scaleFactor)); gcImage.setLineCap(SWT.CAP_ROUND); gcImage.setLineJoin(SWT.JOIN_ROUND); gcImage.setLineStyle(SWT.LINE_SOLID); int[] rgb = tmpStroke.rgb; gcImage.setForeground(new Color(drawArea.getDisplay(), rgb[0], rgb[1], rgb[2])); gcImage.setAlpha(tmpStroke.strokeAlpha); int[] nodes = tmpStroke.getScaledNodes(scaleFactor); // at least 4 values to have two points if (nodes.length > 3) { Path p = new Path(drawArea.getDisplay()); p.moveTo(nodes[0], nodes[1]); for (int j = 2; j < nodes.length - 1; j = j + 2) { p.lineTo(nodes[j], nodes[j + 1]); } gcImage.drawPath(p); } } gc = new GC(drawArea); gc.drawImage(drawnImage, 0, 0); gcImage.dispose(); break; case SWT.MouseMove: if ((event.stateMask & SWT.BUTTON1) == 0) break; if (line == null) break; line.add(event.x); line.add(event.y); gc = new GC(drawArea); gc.setLineWidth((int) Math.round(strokeWidth[0] * scaleFactor)); gc.setLineCap(SWT.CAP_ROUND); gc.setLineJoin(SWT.JOIN_ROUND); gc.setLineStyle(SWT.LINE_SOLID); Color color = new Color(drawArea.getDisplay(), strokeRGB[0], strokeRGB[1], strokeRGB[2]); gc.setForeground(color); gc.setAlpha(255 * strokeAlpha / 100); gc.drawLine(lastX, lastY, event.x, event.y); lastX = event.x; lastY = event.y; gc.dispose(); color.dispose(); break; case SWT.MouseDown: if (isRemoveMode) { break; } lastX = event.x; lastY = event.y; line = new ArrayList<Integer>(); line.add(lastX); line.add(lastY); isDrawMode = true; break; case SWT.MouseUp: if (isRemoveMode || !isDrawMode) break; lastX = event.x; lastY = event.y; DressedStroke newLine = new DressedStroke(); newLine.nodes = new int[line.size()]; for (int i = 0; i < line.size(); i++) { newLine.nodes[i] = (int) Math.round((double) line.get(i) / scaleFactor); } newLine.strokeAlpha = strokeAlpha; newLine.strokeWidth = new int[] { strokeWidth[0] }; newLine.rgb = new int[] { strokeRGB[0], strokeRGB[1], strokeRGB[2] }; lines.add(newLine); line.clear(); drawArea.redraw(); break; } } }; drawArea.addListener(SWT.MouseDown, drawListener); drawArea.addListener(SWT.MouseMove, drawListener); drawArea.addListener(SWT.MouseUp, drawListener); drawArea.addListener(SWT.Paint, drawListener); // add popup menu MenuManager popManager = new MenuManager(); Menu menu = popManager.createContextMenu(drawArea); drawArea.setMenu(menu); IAction menuAction = new SaveAction(this); popManager.add(menuAction); }
From source file:net.tourbook.map2.view.DialogMap2ColorEditor.java
License:Open Source License
private void onSelectColor(final ColorSelector colorSelector, final int valueColorIndex) { // update model final ColorValue colorValue = _mapColorWorkingCopy.getColorValues()[4 - valueColorIndex]; final RGB selectedRGB = colorSelector.getColorValue(); colorValue.red = selectedRGB.red;//from ww w.j a va 2 s . c om colorValue.green = selectedRGB.green; colorValue.blue = selectedRGB.blue; updateUI(); updateUI_LegendImage(); updateModelFromUI(); doLiveUpdate(); }
From source file:net.tourbook.mapping.DialogMappingColor.java
License:Open Source License
private void onSelectColor(final ColorSelector colorSelector, final int valueColorIndex) { // update model final RGB selectedRGB = colorSelector.getColorValue(); final ValueColor colorValue = _colorValueModel[4 - valueColorIndex]; colorValue.red = selectedRGB.red;//from w ww. j ava 2 s . c o m colorValue.green = selectedRGB.green; colorValue.blue = selectedRGB.blue; updateUI(); updateUILegendImage(); updateModelFromUI(); doLiveUpdate(); }