Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 134062 Details for
Bug 266123
improve the capture method and the draw tool
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
capture.patch
capture.patch (text/plain), 84.26 KB, created by
Hiroyuki
on 2009-05-01 10:48:27 EDT
(
hide
)
Description:
capture.patch
Filename:
MIME Type:
Creator:
Hiroyuki
Created:
2009-05-01 10:48:27 EDT
Size:
84.26 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.commons.ui >Index: src/org/eclipse/mylyn/internal/provisional/commons/ui/ScreenshotCreationPage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.commons.ui/src/org/eclipse/mylyn/internal/provisional/commons/ui/ScreenshotCreationPage.java,v >retrieving revision 1.9 >diff -u -r1.9 ScreenshotCreationPage.java >--- src/org/eclipse/mylyn/internal/provisional/commons/ui/ScreenshotCreationPage.java 14 Apr 2009 01:27:36 -0000 1.9 >+++ src/org/eclipse/mylyn/internal/provisional/commons/ui/ScreenshotCreationPage.java 1 May 2009 14:42:31 -0000 >@@ -9,6 +9,7 @@ > * Balazs Brinkus - initial API and implementation > * Tasktop Technologies - improvements > * Willian Mitsuda - improvements >+ * Hiroyuki Inaba - improvements > *******************************************************************************/ > > package org.eclipse.mylyn.internal.provisional.commons.ui; >@@ -16,6 +17,7 @@ > import java.util.ArrayList; > import java.util.EnumSet; > import java.util.HashMap; >+import java.util.HashSet; > import java.util.List; > import java.util.Map; > import java.util.Set; >@@ -32,7 +34,6 @@ > import org.eclipse.jface.layout.GridDataFactory; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.wizard.WizardPage; >-import org.eclipse.mylyn.internal.commons.ui.ColorSelectionWindow; > import org.eclipse.mylyn.internal.commons.ui.Messages; > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.ScrolledComposite; >@@ -46,18 +47,24 @@ > import org.eclipse.swt.events.PaintListener; > import org.eclipse.swt.graphics.Color; > import org.eclipse.swt.graphics.Cursor; >+import org.eclipse.swt.graphics.Font; >+import org.eclipse.swt.graphics.FontData; > import org.eclipse.swt.graphics.GC; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.RGB; > import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.graphics.Region; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.layout.RowLayout; > import org.eclipse.swt.widgets.Canvas; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Display; > import org.eclipse.swt.widgets.Event; >+import org.eclipse.swt.widgets.Listener; > import org.eclipse.swt.widgets.Shell; >-import org.eclipse.swt.widgets.ToolItem; >+import org.eclipse.swt.widgets.Text; > import org.eclipse.ui.progress.UIJob; > > /** >@@ -71,21 +78,31 @@ > */ > public class ScreenshotCreationPage extends WizardPage { > >- private IAction captureAction; >+ private SelectToolAction captureAction; > >- private IAction fitAction; >+ private SelectToolAction fitAction; > > private IAction cropAction; > > private IAction markAction; > >- private IAction colorAction; >+ private IAction clearAction; > >- private Image colorIcon; >+ private IAction undoAction; > >- private Color markColor; >+ private IAction redoAction; > >- private IAction clearAction; >+ private Composite bottomArea; >+ >+ private SelectToolAction drawToolbar; >+ >+ private SelectToolAction lineToolbar; >+ >+ private SelectToolAction boldToolbar; >+ >+ private SelectToolAction colorToolbar; >+ >+ private SelectToolAction fontToolbar; > > private boolean imageDirty; > >@@ -99,6 +116,8 @@ > */ > private Image workImage; > >+ private Image previousImage; >+ > /** > * Used to draw into {@link #workImage} > */ >@@ -155,6 +174,31 @@ > */ > private EditorAction currentAction = EditorAction.CROPPING; > >+ private boolean isFirstCapture = true; >+ >+ /** >+ * Mouse event history. Entry is [0] MouseDown/MouseMove/MouseUp, [1] x, [2] y >+ */ >+ private Text textArea; >+ >+ /** >+ * Mouse event history. Entry is [0] MouseDown/MouseMove/MouseUp, [1] x, [2] y >+ */ >+ private List<int[]> historyMouseEvent = new ArrayList<int[]>(); >+ >+ /** >+ * Draw tool history. Entry is [0] drawHistory index, [1] FREE/LINE/BOX/OVAL, [2] Line type, [3] Bold, [4] R/G/B >+ */ >+ private List<int[]> historyDrawTool = new ArrayList<int[]>(); >+ >+ private List<StringBuffer> historyDrawText = new ArrayList<StringBuffer>(); >+ >+ private List<String> historyDrawFont = new ArrayList<String>(); >+ >+ private int historyCheckpoint = 0; >+ >+ // MouseDown [1, x, y], MouseMove [2, x, y], MouseUp [0, x, y] >+ > public ScreenshotCreationPage() { > super("ScreenShotAttachment"); //$NON-NLS-1$ > setTitle(Messages.ScreenshotCreationPage_CAPTURE_SCRRENSHOT); >@@ -163,7 +207,15 @@ > } > > public void createControl(Composite parent) { >- ViewForm vf = new ViewForm(parent, SWT.BORDER | SWT.FLAT); >+ Composite body = new Composite(parent, SWT.NONE); >+ GridLayout layout = new GridLayout(); >+ layout.horizontalSpacing = 0; >+ layout.verticalSpacing = 0; >+ layout.marginWidth = 0; >+ layout.marginHeight = 0; >+ body.setLayout(layout); >+ >+ ViewForm vf = new ViewForm(body, SWT.BORDER | SWT.FLAT); > vf.horizontalSpacing = 0; > vf.verticalSpacing = 0; > setControl(vf); >@@ -173,13 +225,21 @@ > > // TODO: need disabled versions of all toolbar icons > ToolBarManager tbm = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT); >- captureAction = new Action(Messages.ScreenshotCreationPage_Capture_Desktop_C, IAction.AS_PUSH_BUTTON) { > >- private boolean isFirstCapture = true; >+ captureAction = new SelectToolAction(getShell(), Messages.ScreenshotCreationPage_Capture_Desktop_C, >+ SelectToolAction.CAPTURE_DROP_DOWN_MENU) { > > @Override > public void run() { >- captureScreenshotContent(); >+ if (captureAction.getSelect() == SelectToolAction.CAPTURE_DESKTOP) { >+ captureScreenshotContent(); >+ } else if (captureAction.getSelect() == SelectToolAction.CAPTURE_CLIPBOARD) { >+ captureScreenshotContent(captureAction.getClipboardImage()); >+ } else if (captureAction.getSelect() == SelectToolAction.CAPTURE_RECTANGLE) { >+ captureScreenshotContentFromSelection(); >+ } else { >+ captureScreenshotContent(captureAction.getFileImage()); >+ } > setErrorMessage(null); > if (isFirstCapture) { > isFirstCapture = false; >@@ -188,12 +248,27 @@ > cropAction.setChecked(true); > markAction.setEnabled(true); > clearAction.setEnabled(false); >+ >+ disposeBottomToolbars(); > } >+ >+ historyMouseEvent = new ArrayList<int[]>(); >+ historyDrawTool = new ArrayList<int[]>(); >+ historyDrawText = new ArrayList<StringBuffer>(); >+ historyDrawFont = new ArrayList<String>(); >+ historyCheckpoint = 0; >+ undoAction.setEnabled(false); >+ redoAction.setEnabled(false); > } > >+ @Override >+ protected boolean isEnableRectangle() { >+ return (currentSelection != null); >+ } > }; > captureAction.setToolTipText(Messages.ScreenshotCreationPage_Capture_Desktop); > captureAction.setImageDescriptor(ImageDescriptor.createFromImage(CommonImages.getImage(CommonImages.IMAGE_CAPTURE))); >+ captureAction.setShowMenuAlways(false); > > // captureDelayedButton = new Button(buttonsComposite, SWT.PUSH); > // final String captureIn = "Capture in "; >@@ -228,16 +303,16 @@ > // } > // }); > >- fitAction = new Action("", IAction.AS_CHECK_BOX) { //$NON-NLS-1$ >+ fitAction = new SelectToolAction(Messages.ScreenshotCreationPage_Fit_Image_F, >+ SelectToolAction.ZOOM_DROP_DOWN_MENU) { > @Override > public void run() { > refreshCanvasSize(); > } > }; > fitAction.setToolTipText(Messages.ScreenshotCreationPage_Fit_Image); >- fitAction.setText(Messages.ScreenshotCreationPage_Fit_Image_F); > fitAction.setImageDescriptor(ImageDescriptor.createFromImage(CommonImages.getImage(CommonImages.IMAGE_FIT))); >- fitAction.setChecked(true); >+ //fitAction.setChecked(true); > fitAction.setEnabled(false); > > cropAction = new Action(Messages.ScreenshotCreationPage_Crop_R, IAction.AS_RADIO_BUTTON) { >@@ -246,8 +321,11 @@ > currentAction = EditorAction.CROPPING; > cropAction.setChecked(true); > markAction.setChecked(false); >- colorAction.setEnabled(false); >+ undoAction.setEnabled(false); >+ redoAction.setEnabled(false); > canvas.redraw(); >+ >+ disposeBottomToolbars(); > } > }; > cropAction.setToolTipText(Messages.ScreenshotCreationPage_Crop); >@@ -260,8 +338,12 @@ > currentAction = EditorAction.MARKING; > cropAction.setChecked(false); > markAction.setChecked(true); >- colorAction.setEnabled(true); >+// fontAction.setEnabled(toolAction.getSelect() == SelectToolAction.DRAW_TEXT); >+ undoAction.setEnabled(false); >+ redoAction.setEnabled(false); > canvas.redraw(); >+ >+ createBottomToolbars(); > } > }; > markAction.setToolTipText(Messages.ScreenshotCreationPage_DRAW_ANNOTATION_ON_SCREENSHOT_IMAGE); >@@ -269,56 +351,75 @@ > // markAction.setDisabledImageDescriptor(ImageDescriptor.createFromFile(getClass(), "mark_disabled.gif")); > markAction.setEnabled(false); > >- colorAction = new Action("", IAction.AS_DROP_DOWN_MENU) { //$NON-NLS-1$ >- @Override >- public void runWithEvent(final Event e) { >- final ColorSelectionWindow colorWindow = new ColorSelectionWindow(getControl().getShell()) { >- >- @Override >- protected Point getInitialLocation(Point initialSize) { >- ToolItem toolItem = (ToolItem) e.widget; >- Rectangle itemBounds = toolItem.getBounds(); >- Point location = toolItem.getParent().toDisplay(itemBounds.x + itemBounds.width, >- itemBounds.y + itemBounds.height); >- location.x -= initialSize.x; >- return location; >- } >- >- }; >- colorWindow.setBlockOnOpen(true); >- colorWindow.open(); >- RGB color = colorWindow.getSelectedRGB(); >- if (color != null) { >- setMarkColor(color); >- } >- } >- }; >- colorAction.setToolTipText(Messages.ScreenshotCreationPage_Change_pen_color); >- colorIcon = new Image(getShell().getDisplay(), 16, 16); >- setMarkColor(new RGB(255, 85, 85)); >- colorAction.setEnabled(false); >- >- clearAction = new Action(Messages.ScreenshotCreationPage_Clear_Annotations, IAction.AS_PUSH_BUTTON) { >+ clearAction = new Action(Messages.ScreenshotCreationPage_Clear, IAction.AS_PUSH_BUTTON) { > @Override > public void run() { > clearAction.setEnabled(false); > workImageGC.drawImage(originalImage, 0, 0); > canvas.redraw(); > setImageDirty(true); >+ >+ historyMouseEvent = new ArrayList<int[]>(); >+ historyDrawTool = new ArrayList<int[]>(); >+ historyDrawText = new ArrayList<StringBuffer>(); >+ historyDrawFont = new ArrayList<String>(); >+ historyCheckpoint = 0; >+ undoAction.setEnabled(false); >+ redoAction.setEnabled(false); > } > }; > clearAction.setToolTipText(Messages.ScreenshotCreationPage_Clear_all_annotations_made_on_screenshot_image); > clearAction.setImageDescriptor(CommonImages.CLEAR); > clearAction.setEnabled(false); > >+ undoAction = new Action(Messages.ScreenshotCreationPage_Undo) { >+ @Override >+ public void run() { >+ if (historyCheckpoint > 0) { >+ historyCheckpoint--; >+ drawAnnotationHistory(); >+ } >+ if (historyCheckpoint == 0) { >+ undoAction.setEnabled(false); >+ } >+ if (historyCheckpoint < historyDrawTool.size()) { >+ redoAction.setEnabled(true); >+ } >+ } >+ }; >+ undoAction.setToolTipText(Messages.ScreenshotCreationPage_Undo_annotation); >+ undoAction.setImageDescriptor(CommonImages.EDIT_UNDO); >+ undoAction.setEnabled(false); >+ >+ redoAction = new Action(Messages.ScreenshotCreationPage_Redo) { >+ @Override >+ public void run() { >+ if (historyCheckpoint < historyDrawTool.size()) { >+ historyCheckpoint++; >+ drawAnnotationHistory(); >+ } >+ if (historyCheckpoint > 0) { >+ undoAction.setEnabled(true); >+ } >+ if (historyCheckpoint >= historyDrawTool.size()) { >+ redoAction.setEnabled(false); >+ } >+ } >+ }; >+ redoAction.setToolTipText(Messages.ScreenshotCreationPage_Redo_annotation); >+ redoAction.setImageDescriptor(CommonImages.EDIT_REDO); >+ redoAction.setEnabled(false); >+ > tbm.add(createAndConfigureCI(captureAction)); >- tbm.add(createAndConfigureCI(fitAction)); > tbm.add(new Separator()); >+ tbm.add(createAndConfigureCI(fitAction)); > tbm.add(createAndConfigureCI(cropAction)); > tbm.add(createAndConfigureCI(markAction)); >- tbm.add(createAndConfigureCI(colorAction)); > tbm.add(new Separator()); > tbm.add(createAndConfigureCI(clearAction)); >+ tbm.add(createAndConfigureCI(undoAction)); >+ tbm.add(createAndConfigureCI(redoAction)); >+ tbm.add(new Separator()); > > scrolledComposite = new ScrolledComposite(vf, SWT.V_SCROLL | SWT.H_SCROLL); > canvas = new Canvas(scrolledComposite, SWT.DOUBLE_BUFFERED); >@@ -330,11 +431,23 @@ > Rectangle imageBounds = workImage.getBounds(); > Rectangle canvasBounds = canvas.getClientArea(); > >- if (fitAction.isChecked()) { >- e.gc.drawImage(workImage, 0, 0, imageBounds.width, imageBounds.height, 0, 0, >- canvasBounds.width, canvasBounds.height); >- } else { >+ int zoom = fitAction.getSelect(); >+ switch (zoom) { >+ case SelectToolAction.ZOOM_FIT: >+ e.gc.drawImage(workImage, 0, 0, imageBounds.width, imageBounds.height, // >+ 0, 0, canvasBounds.width, canvasBounds.height); >+ break; >+ case 50: >+ e.gc.drawImage(workImage, 0, 0, imageBounds.width, imageBounds.height, // >+ 0, 0, imageBounds.width / 2, imageBounds.height / 2); >+ break; >+ case 100: > e.gc.drawImage(workImage, 0, 0); >+ break; >+ default: >+ e.gc.drawImage(workImage, 0, 0, imageBounds.width, imageBounds.height, // >+ 0, 0, imageBounds.width * zoom / 100, imageBounds.height * zoom / 100); >+ break; > } > drawSelection(e.gc); > } else { >@@ -347,7 +460,7 @@ > scrolledComposite.addControlListener(new ControlAdapter() { > @Override > public void controlResized(ControlEvent e) { >- if (fitAction.isChecked()) { >+ if (fitAction.getSelect() == SelectToolAction.ZOOM_FIT) { > refreshCanvasSize(); > } > } >@@ -358,42 +471,130 @@ > vf.setContent(scrolledComposite); > registerMouseListeners(); > >+ vf.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ > Dialog.applyDialogFont(vf); > } > >- private ActionContributionItem createAndConfigureCI(IAction action) { >- ActionContributionItem ci = new ActionContributionItem(action); >- ci.setMode(ActionContributionItem.MODE_FORCE_TEXT); >- return ci; >- } >+ private void disposeBottomToolbars() { >+ if (bottomArea == null) { >+ return; >+ } >+ if (drawToolbar != null) { >+ drawToolbar.dispose(); >+ drawToolbar = null; >+ } >+ if (lineToolbar != null) { >+ lineToolbar.dispose(); >+ lineToolbar = null; >+ } >+ if (boldToolbar != null) { >+ boldToolbar.dispose(); >+ boldToolbar = null; >+ } >+ if (colorToolbar != null) { >+ colorToolbar.dispose(); >+ colorToolbar = null; >+ } >+ if (fontToolbar != null) { >+ fontToolbar.dispose(); >+ fontToolbar = null; >+ } >+ bottomArea.dispose(); >+ bottomArea = null; >+ getControl().getParent().layout(); >+ } >+ >+ private void createBottomToolbars() { >+ Composite body = getControl().getParent(); >+ if (bottomArea == null) { >+ bottomArea = new Composite(body, SWT.NONE); >+ bottomArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ RowLayout layout = new RowLayout(); >+ layout.marginTop = 0; >+ layout.marginBottom = 1; >+ layout.marginLeft = 1; >+ layout.marginRight = 1; >+ layout.marginRight = 1; >+ bottomArea.setLayout(layout); >+ bottomArea.addListener(SWT.Paint, new Listener() { >+ public void handleEvent(Event e) { >+ Color gcForeground = e.gc.getForeground(); >+ Rectangle bounds = ((Composite) e.widget).getBounds(); >+ Color border = e.widget.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW); >+ e.gc.setForeground(border); >+ e.gc.drawLine(0, 0, 0, bounds.height - 1); >+ e.gc.drawLine(0, bounds.height - 1, bounds.width - 1, bounds.height - 1); >+ e.gc.drawLine(bounds.width - 1, 0, bounds.width - 1, bounds.height - 1); >+ e.gc.setForeground(gcForeground); >+ } >+ }); >+ } >+ >+ if (drawToolbar == null) { >+ drawToolbar = new SelectToolAction(bottomArea, SelectToolAction.DRAW_TOOLBAR) { > >- private void setMarkColor(RGB color) { >- if (markColor != null) { >- markColor.dispose(); >+ @Override >+ public void run() { >+ if (drawToolbar.getSelect() != SelectToolAction.DRAW_TEXT) { >+ if (fontToolbar != null) { >+ createBottomToolbars(); >+ } >+ } else { >+ if (fontToolbar == null) { >+ createBottomToolbars(); >+ } >+ } >+ } >+ }; > } >- markColor = new Color(getShell().getDisplay(), color); >- if (workImageGC != null) { >- workImageGC.setForeground(markColor); >+ if (drawToolbar.getSelect() != SelectToolAction.DRAW_TEXT) { >+ if (fontToolbar != null) { >+ fontToolbar.dispose(); >+ fontToolbar = null; >+ } >+ if (lineToolbar == null) { >+ lineToolbar = new SelectToolAction(bottomArea, SelectToolAction.LINE_TOOLBAR); >+ } >+ if (boldToolbar == null) { >+ boldToolbar = new SelectToolAction(bottomArea, SelectToolAction.BOLD_TOOLBAR); >+ } >+ if (colorToolbar == null) { >+ colorToolbar = new SelectToolAction(bottomArea, SelectToolAction.COLOR_TOOLBAR); >+ } >+ } else { >+ if (lineToolbar != null) { >+ lineToolbar.dispose(); >+ lineToolbar = null; >+ } >+ if (boldToolbar != null) { >+ boldToolbar.dispose(); >+ boldToolbar = null; >+ } >+ if (colorToolbar != null) { >+ colorToolbar.dispose(); >+ colorToolbar = null; >+ } >+ if (fontToolbar == null) { >+ fontToolbar = new SelectToolAction(bottomArea, SelectToolAction.FONT_TOOLBAR); >+ } > } > >- GC colorGC = new GC(colorIcon); >- colorGC.setBackground(markColor); >- colorGC.fillRectangle(0, 0, 16, 16); >- colorGC.drawRectangle(0, 0, 15, 15); >- colorGC.dispose(); >+ Dialog.applyDialogFont(bottomArea); >+ bottomArea.layout(); >+ body.layout(); >+ } > >- colorAction.setImageDescriptor(ImageDescriptor.createFromImage(colorIcon)); >+ private ActionContributionItem createAndConfigureCI(IAction action) { >+ ActionContributionItem ci = new ActionContributionItem(action); >+ ci.setMode(ActionContributionItem.MODE_FORCE_TEXT); >+ return ci; > } > > @Override > public void dispose() { >+ disposeBottomToolbars(); > disposeImageResources(); >- if (markColor != null) { >- markColor.dispose(); >- } >- if (colorIcon != null) { >- colorIcon.dispose(); >- } > > canvas.setCursor(null); > for (Cursor cursor : cursors.values()) { >@@ -440,11 +641,74 @@ > int y = (int) Math.round(currentSelection.y * scaleFactor); > int right = (int) Math.round((currentSelection.x + currentSelection.width) * scaleFactor); > int bottom = (int) Math.round((currentSelection.y + currentSelection.height) * scaleFactor); >- int width = Math.min(right, (int) Math.round((workImage.getBounds().width - 1) * scaleFactor)) - x; >- int height = Math.min(bottom, (int) Math.round((workImage.getBounds().height - 1) * scaleFactor)) - y; >+ int width = Math.min(right, (int) Math.round(workImage.getBounds().width * scaleFactor)) - x; >+ int height = Math.min(bottom, (int) Math.round(workImage.getBounds().height * scaleFactor)) - y; > return new Rectangle(x, y, width, height); > } > >+ private Rectangle getOutsideSelection(Rectangle rectangle) { >+ if (rectangle == null) { >+ return null; >+ } >+ return new Rectangle(rectangle.x - SQUARE_SIZE * 2, rectangle.y - SQUARE_SIZE * 2, // >+ rectangle.width + SQUARE_SIZE * 4 + 1, rectangle.height + SQUARE_SIZE * 4 + 1); >+ } >+ >+ private static final int[][] grapGroupPoints = { // >+ /* */{ 0, 0, 0 }, { 1, 0, 0 }, { 2, 0, 1 }, { 3, 0, 2 }, { 4, 0, 2 }, // >+ { 0, 1, 0 }, /* *//* *//* */{ 4, 1, 2 }, // >+ { 0, 2, 3 }, /* *//* *//* */{ 4, 2, 4 }, // >+ { 0, 3, 5 }, /* *//* *//* */{ 4, 3, 7 }, // >+ { 0, 4, 5 }, { 1, 4, 5 }, { 2, 4, 6 }, { 3, 4, 7 }, { 4, 4, 7 } }; >+ >+ private static final int[] grapScanOrder = { 0, 4, 1, 3, 2 }; >+ >+ private int getGrabPoint(int x, int y) { >+ if (currentSelection == null) { >+ return -1; >+ } >+ >+ Rectangle inside = getScaledSelection(); >+ Rectangle outside = getOutsideSelection(inside); >+ int[] xGroupPoint = { outside.x, // >+ inside.x, // >+ inside.x + SQUARE_SIZE * 4, // >+ inside.x + inside.width - SQUARE_SIZE * 4, // >+ inside.x + inside.width, // >+ outside.x + outside.width }; >+ int[] yGroupPoint = { outside.y, // >+ inside.y, // >+ inside.y + SQUARE_SIZE * 4, // >+ inside.y + inside.height - SQUARE_SIZE * 4, // >+ inside.y + inside.height, // >+ outside.y + outside.height }; >+ int xGroup = -1, yGroup = -1; >+ for (int element : grapScanOrder) { >+ if (xGroupPoint[element] <= x && x <= xGroupPoint[element + 1]) { >+ xGroup = element; >+ break; >+ } >+ } >+ if (xGroup < 0) { >+ return -1; >+ } >+ for (int element : grapScanOrder) { >+ if (yGroupPoint[element] <= y && y <= yGroupPoint[element + 1]) { >+ yGroup = element; >+ break; >+ } >+ } >+ if (yGroup < 0) { >+ return -1; >+ } >+ for (int[] element : grapGroupPoints) { >+ if (element[0] == xGroup && element[1] == yGroup) { >+ return element[2]; >+ } >+ } >+ return -1; >+ } >+ > @Override > public boolean isPageComplete() { > return workImage != null; >@@ -455,6 +719,53 @@ > return isPageComplete(); > } > >+ private void captureScreenshotContent(Image image) { >+ final Display display = getShell().getDisplay(); >+ disposeImageResources(); >+ originalImage = image; >+ Rectangle displayBounds = originalImage.getBounds(); >+ workImage = new Image(display, displayBounds.width, displayBounds.height); >+ GC gc = new GC(workImage); >+ gc.drawImage(originalImage, 0, 0); >+ gc.dispose(); >+ >+ workImageGC = new GC(workImage); >+ workImageGC.setLineCap(SWT.CAP_ROUND); >+ >+ scrolledComposite.setEnabled(true); >+ clearSelection(); >+ refreshCanvasSize(); >+ >+ setPageComplete(true); >+ } >+ >+ private void captureScreenshotContentFromSelection() { >+ Display display = getShell().getDisplay(); >+ >+ Image image = new Image(display, currentSelection); >+ GC gc = new GC(image); >+ gc.drawImage(workImage, currentSelection.x, currentSelection.y, currentSelection.width, >+ currentSelection.height, 0, 0, currentSelection.width, currentSelection.height); >+ gc.dispose(); >+ disposeImageResources(); >+ >+ originalImage = image; >+ Rectangle displayBounds = originalImage.getBounds(); >+ workImage = new Image(display, displayBounds.width, displayBounds.height); >+ gc = new GC(workImage); >+ gc.drawImage(originalImage, 0, 0); >+ gc.dispose(); >+ >+ workImageGC = new GC(workImage); >+ workImageGC.setLineCap(SWT.CAP_ROUND); >+ >+ scrolledComposite.setEnabled(true); >+ clearSelection(); >+ refreshCanvasSize(); >+ >+ setPageComplete(true); >+ } >+ > private void captureScreenshotContent() { > final Display display = getShell().getDisplay(); > final Shell wizardShell = getWizard().getContainer().getShell(); >@@ -476,8 +787,6 @@ > gc.dispose(); > > workImageGC = new GC(workImage); >- workImageGC.setForeground(markColor); >- workImageGC.setLineWidth(4); > workImageGC.setLineCap(SWT.CAP_ROUND); > > scrolledComposite.setEnabled(true); >@@ -514,34 +823,13 @@ > currentSelection.intersect(imageBounds); > } > >- /** >- * Create the grab points to resize the selection; this method should be called every time the selection or zoom >- * level is changed >- */ >- private void setUpGrabPoints() { >- grabPoints.clear(); >- if (currentSelection == null) { >- return; >- } >+ private static final int grabPointCurosr[] = { SWT.CURSOR_SIZENWSE, SWT.CURSOR_SIZENS, SWT.CURSOR_SIZENESW, >+ SWT.CURSOR_SIZEWE, SWT.CURSOR_SIZEWE, SWT.CURSOR_SIZENESW, SWT.CURSOR_SIZENS, SWT.CURSOR_SIZENWSE }; > >- Rectangle scaledSelection = getScaledSelection(); >- grabPoints.add(GrabPoint.createGrabPoint(scaledSelection.x, scaledSelection.y, SWT.CURSOR_SIZENWSE, EnumSet.of( >- SelectionSide.LEFT, SelectionSide.TOP))); >- grabPoints.add(GrabPoint.createGrabPoint(scaledSelection.x + scaledSelection.width / 2, scaledSelection.y, >- SWT.CURSOR_SIZENS, EnumSet.of(SelectionSide.TOP))); >- grabPoints.add(GrabPoint.createGrabPoint(scaledSelection.x + scaledSelection.width, scaledSelection.y, >- SWT.CURSOR_SIZENESW, EnumSet.of(SelectionSide.TOP, SelectionSide.RIGHT))); >- grabPoints.add(GrabPoint.createGrabPoint(scaledSelection.x, scaledSelection.y + scaledSelection.height / 2, >- SWT.CURSOR_SIZEWE, EnumSet.of(SelectionSide.LEFT))); >- grabPoints.add(GrabPoint.createGrabPoint(scaledSelection.x + scaledSelection.width, scaledSelection.y >- + scaledSelection.height / 2, SWT.CURSOR_SIZEWE, EnumSet.of(SelectionSide.RIGHT))); >- grabPoints.add(GrabPoint.createGrabPoint(scaledSelection.x, scaledSelection.y + scaledSelection.height, >- SWT.CURSOR_SIZENESW, EnumSet.of(SelectionSide.LEFT, SelectionSide.BOTTOM))); >- grabPoints.add(GrabPoint.createGrabPoint(scaledSelection.x + scaledSelection.width / 2, scaledSelection.y >- + scaledSelection.height, SWT.CURSOR_SIZENS, EnumSet.of(SelectionSide.BOTTOM))); >- grabPoints.add(GrabPoint.createGrabPoint(scaledSelection.x + scaledSelection.width, scaledSelection.y >- + scaledSelection.height, SWT.CURSOR_SIZENWSE, EnumSet.of(SelectionSide.BOTTOM, SelectionSide.RIGHT))); >- } >+ private static final SelectionSide[][] grabPointResizableSides = { { SelectionSide.LEFT, SelectionSide.TOP }, >+ { SelectionSide.TOP }, { SelectionSide.TOP, SelectionSide.RIGHT }, { SelectionSide.LEFT }, >+ { SelectionSide.RIGHT }, { SelectionSide.LEFT, SelectionSide.BOTTOM }, { SelectionSide.BOTTOM }, >+ { SelectionSide.BOTTOM, SelectionSide.RIGHT } }; > > private void refreshSelectionResize(int x, int y) { > currentSelection = new Rectangle(originalSelection.x, originalSelection.y, originalSelection.width, >@@ -559,7 +847,7 @@ > } > if (resizableSides.contains(SelectionSide.RIGHT)) { > deltaX = Math.max(deltaX, -originalSelection.width); >- if (originalSelection.x + originalSelection.width + deltaX - 1 > imageBounds.width) { >+ if (originalSelection.x + originalSelection.width + deltaX > imageBounds.width) { > deltaX = imageBounds.width - (originalSelection.x + originalSelection.width); > } > } >@@ -571,7 +859,7 @@ > } > if (resizableSides.contains(SelectionSide.BOTTOM)) { > deltaY = Math.max(deltaY, -originalSelection.height); >- if (originalSelection.y + originalSelection.height + deltaY - 1 > imageBounds.height) { >+ if (originalSelection.y + originalSelection.height + deltaY > imageBounds.height) { > deltaY = imageBounds.height - (originalSelection.y + originalSelection.height); > } > } >@@ -591,8 +879,6 @@ > if (resizableSides.contains(SelectionSide.BOTTOM)) { > currentSelection.height += deltaY; > } >- >- setUpGrabPoints(); > } > > private void refreshSelectionPosition(int x, int y) { >@@ -605,15 +891,13 @@ > newY = 0; > } > Rectangle imageBounds = workImage.getBounds(); >- if (newX + originalSelection.width - 1 > imageBounds.width) { >+ if (newX + originalSelection.width > imageBounds.width) { > newX = imageBounds.width - originalSelection.width; > } >- if (newY + originalSelection.height - 1 > imageBounds.height) { >+ if (newY + originalSelection.height > imageBounds.height) { > newY = imageBounds.height - originalSelection.height; > } > currentSelection = new Rectangle(newX, newY, originalSelection.width, originalSelection.height); >- >- setUpGrabPoints(); > } > > private void registerMouseListeners() { >@@ -639,12 +923,10 @@ > boolean cursorSet = false; > > // No selection in course, but have something selected; first test if I'm hovering some grab point >- for (GrabPoint point : grabPoints) { >- if (point.grabArea.contains(e.x, e.y)) { >- canvas.setCursor(cursors.get(point.cursorType)); >- cursorSet = true; >- break; >- } >+ int info = getGrabPoint(e.x, e.y); >+ if (info >= 0) { >+ canvas.setCursor(cursors.get(grabPointCurosr[info])); >+ cursorSet = true; > } > > // Test if I'm inside selection, so I can move it >@@ -659,6 +941,28 @@ > canvas.setCursor(crossCursor); > } > } else if (currentAction == EditorAction.MARKING) { >+ if (startPoint != null) { >+ if (drawToolbar.getSelect() == SelectToolAction.DRAW_FREE) { >+ int[] history = new int[3]; >+ history[0] = SWT.MouseMove; >+ history[1] = scaledX; >+ history[2] = scaledY; >+ historyMouseEvent.add(history); >+ } else { >+ int[] history = historyMouseEvent.get(historyMouseEvent.size() - 1); >+ if (history[0] == SWT.MouseMove) { >+ history[1] = scaledX; >+ history[2] = scaledY; >+ } else { >+ history = new int[3]; >+ history[0] = SWT.MouseMove; >+ history[1] = scaledX; >+ history[2] = scaledY; >+ historyMouseEvent.add(history); >+ } >+ } >+ } >+ > drawMarkLine(scaledX, scaledY); > > Cursor markCursor = cursors.get(CURSOR_MARK_TOOL); >@@ -667,7 +971,6 @@ > } > } > } >- > }); > > canvas.addMouseListener(new MouseAdapter() { >@@ -692,19 +995,152 @@ > if (currentSelection.width == 0 && currentSelection.height == 0) { > currentSelection = null; > } >- setUpGrabPoints(); >+ > startPoint = null; > currentAction = EditorAction.CROPPING; > > canvas.redraw(); > setImageDirty(true); > } else if (currentAction == EditorAction.MARKING) { >+ if (startPoint != null) { >+ if (drawToolbar.getSelect() != SelectToolAction.DRAW_FREE) { >+ if (drawToolbar.getSelect() == SelectToolAction.DRAW_TEXT) { >+ drawAnnotationText(); >+ } >+ previousImage.dispose(); >+ previousImage = null; >+ } >+ >+ int[] history = new int[3]; >+ history[0] = SWT.MouseUp; >+ history[1] = 0; >+ history[2] = 0; >+ historyMouseEvent.add(history); >+ } >+ > startPoint = null; > setImageDirty(true); > } > } > > /** >+ * Input annotation text and draw text >+ */ >+ private void drawAnnotationText() { >+ workImageGC.drawImage(previousImage, 0, 0); >+ canvas.redraw(); >+ >+ int[] history = historyMouseEvent.get(historyMouseEvent.size() - 1); >+ if (history[0] != SWT.MouseMove) { >+ historyCheckpoint--; >+ updateAnnotationHistory(); >+ return; >+ } >+ >+ int endedPoint_x, endedPoint_y; >+ if (history[1] < startPoint.x) { >+ endedPoint_x = startPoint.x; >+ startPoint.x = history[1]; >+ } else { >+ endedPoint_x = history[1]; >+ } >+ if (history[2] < startPoint.y) { >+ endedPoint_y = startPoint.y; >+ startPoint.y = history[2]; >+ } else { >+ endedPoint_y = history[2]; >+ } >+ final Rectangle bounds = new Rectangle(startPoint.x, startPoint.y, endedPoint_x - startPoint.x, >+ endedPoint_y - startPoint.y); >+ textArea = new Text(canvas, SWT.MULTI | SWT.WRAP); >+ int xs = (int) Math.round(startPoint.x * scaleFactor); >+ int ys = (int) Math.round(startPoint.y * scaleFactor); >+ int xe = (int) Math.round(endedPoint_x * scaleFactor); >+ int ye = (int) Math.round(endedPoint_y * scaleFactor); >+ textArea.setBounds(new Rectangle(xs, ys, xe - xs, ye - ys)); >+ FontData fontData = new FontData(fontToolbar.getStringCustom()); >+ if (scaleFactor != 1.0) { >+ fontData.setHeight((int) Math.round(fontData.getHeight() * scaleFactor)); >+ } >+ textArea.setFont(new Font(getShell().getDisplay(), fontData)); >+ textArea.setForeground(new Color(getShell().getDisplay(), >+ SelectToolAction.int2rgb(fontToolbar.getIntgerCustom()))); >+ textArea.setTabs(1); >+ Point point = textArea.getCaretLocation(); >+ textArea.setBounds(new Rectangle(xs - point.x, ys, xe - xs + point.x + point.x, ye - ys)); >+ textArea.setFocus(); >+ textArea.addListener(SWT.Deactivate, new Listener() { >+ >+ public void handleEvent(Event event) { >+ String text = textArea.getText(); >+ { >+ String newtext = ""; //$NON-NLS-1$ >+ int currpos = 0; >+ int charpos = currpos; >+ textArea.setTopIndex(0); >+ textArea.setSelection(currpos); >+ int linepos = textArea.getCaretLineNumber(); >+ boolean remove1st = false; >+ String line; >+ while (currpos < text.length()) { >+ int y = textArea.getCaretLineNumber(); >+ if (linepos != y) { >+ line = text.substring(charpos, currpos); >+ if (line.endsWith("\n")) { //$NON-NLS-1$ >+ line = line.substring(0, line.length() - 1); >+ } >+ newtext = newtext + "\n" + line; //$NON-NLS-1$ >+ remove1st = true; >+ charpos = currpos; >+ linepos = y; >+ } >+ currpos++; >+ textArea.setSelection(currpos); >+ } >+ line = text.substring(charpos, currpos); >+ if (line.endsWith("\n")) { //$NON-NLS-1$ >+ line = line.substring(0, line.length() - 1); >+ } >+ if (line.length() > 0) { >+ newtext = newtext + "\n" + text.substring(charpos, currpos); //$NON-NLS-1$ >+ remove1st = true; >+ } >+ currpos = newtext.indexOf("\r"); //$NON-NLS-1$ >+ while (currpos > 0) { >+ newtext = newtext.substring(0, currpos) + newtext.substring(currpos + 1); >+ currpos = newtext.indexOf("\r"); //$NON-NLS-1$ >+ } >+ newtext = newtext.replace("\t", " "); //$NON-NLS-1$//$NON-NLS-2$ >+ if (remove1st) { >+ newtext = newtext.substring(1); >+ } >+ text = newtext; >+ } >+ >+ textArea.dispose(); >+ textArea = null; >+ >+ if (text.length() > 0) { >+ historyDrawText.get(historyCheckpoint - 1).append(text); >+ Color color = workImageGC.getForeground(); >+ FontData fontData = new FontData(fontToolbar.getStringCustom()); >+ workImageGC.setFont(new Font(getShell().getDisplay(), fontData)); >+ workImageGC.setForeground(new Color(getShell().getDisplay(), >+ SelectToolAction.int2rgb(fontToolbar.getIntgerCustom()))); >+ workImageGC.setClipping(bounds); >+ workImageGC.drawText(text, bounds.x, bounds.y, true); >+ workImageGC.setClipping((Rectangle) null); >+ workImageGC.setForeground(color); >+ } else { >+ historyCheckpoint--; >+ updateAnnotationHistory(); >+ } >+ canvas.redraw(); >+ } >+ }); >+ } >+ >+ /** > * Pressing mouse button starts a selection or a drawing; normalizes and marks the start point > */ > @Override >@@ -713,6 +1149,57 @@ > int scaledY = (int) (e.y / scaleFactor); > > if (currentAction == EditorAction.MARKING) { >+ updateAnnotationHistory(); >+ >+ int toolKind = drawToolbar.getSelect(); >+ int[] history = new int[5]; >+ history[0] = historyMouseEvent.size(); >+ history[1] = drawToolbar.getSelect(); >+ history[2] = (lineToolbar != null) ? lineToolbar.getSelect() : 0; >+ history[3] = (boldToolbar != null) ? boldToolbar.getSelect() : 0; >+ RGB rgb; >+ if (toolKind == SelectToolAction.DRAW_TEXT) { >+ rgb = SelectToolAction.int2rgb(fontToolbar.getIntgerCustom()); >+ } else { >+ rgb = SelectToolAction.int2rgb(colorToolbar.getSelect()); >+ } >+ history[4] = (rgb.red << 16) + (rgb.green << 8) + rgb.blue; >+ historyDrawTool.add(history); >+ historyDrawText.add(new StringBuffer()); >+ if (toolKind == SelectToolAction.DRAW_TEXT) { >+ FontData fontData = new FontData(fontToolbar.getStringCustom()); >+ historyDrawFont.add(fontData.toString()); >+ } else { >+ historyDrawFont.add(""); //$NON-NLS-1$ >+ } >+ historyCheckpoint = historyDrawTool.size(); >+ >+ history = new int[3]; >+ history[0] = SWT.MouseDown; >+ history[1] = scaledX; >+ history[2] = scaledY; >+ historyMouseEvent.add(history); >+ undoAction.setEnabled(true); >+ >+ if (toolKind != SelectToolAction.DRAW_FREE) { >+ Display display = getShell().getDisplay(); >+ previousImage = new Image(display, workImage.getBounds()); >+ GC gc = new GC(previousImage); >+ gc.drawImage(workImage, 0, 0); >+ gc.dispose(); >+ } >+ >+ if (toolKind != SelectToolAction.DRAW_TEXT) { >+ workImageGC.setLineStyle(lineToolbar.getSelect()); >+ workImageGC.setLineWidth(boldToolbar.getSelect()); >+ workImageGC.setForeground(new Color(getShell().getDisplay(), >+ SelectToolAction.int2rgb(colorToolbar.getSelect()))); >+ } else { >+ workImageGC.setLineStyle(SWT.LINE_DOT); >+ workImageGC.setLineWidth(1); >+ workImageGC.setForeground(new Color(getShell().getDisplay(), 0, 0, 0)); >+ } >+ > startPoint = new Point(scaledX, scaledY); > drawMarkLine(scaledX, scaledY); > canvas.setCursor(cursors.get(CURSOR_MARK_TOOL)); >@@ -723,15 +1210,17 @@ > > // Check the most appropriate action to follow; first check if I'm on some grab point > if (currentSelection != null) { >- for (GrabPoint point : grabPoints) { >- if (point.grabArea.contains(e.x, e.y)) { >- originalSelection = currentSelection; >- currentAction = EditorAction.RESIZING_SELECTION; >- resizableSides = point.resizableSides; >- startPoint = new Point(scaledX, scaledY); >- canvas.redraw(); >- return; >+ int info = getGrabPoint(e.x, e.y); >+ if (info >= 0) { >+ originalSelection = currentSelection; >+ currentAction = EditorAction.RESIZING_SELECTION; >+ resizableSides = new HashSet<SelectionSide>(); >+ for (SelectionSide side : grabPointResizableSides[info]) { >+ resizableSides.add(side); > } >+ startPoint = new Point(scaledX, scaledY); >+ canvas.redraw(); >+ return; > } > } > >@@ -749,12 +1238,10 @@ > currentAction = EditorAction.SELECTING; > currentSelection = null; > startPoint = new Point(scaledX, scaledY); >- setUpGrabPoints(); >+ > canvas.redraw(); > } >- > }); >- > } > > private void clearSelection() { >@@ -779,7 +1266,7 @@ > * Calling this method under other circumstances may lead to strange behavior in the scrolled composite > */ > private void refreshCanvasSize() { >- if (fitAction.isChecked()) { >+ if (fitAction.getSelect() == SelectToolAction.ZOOM_FIT) { > // This little hack is necessary to get the client area without scrollbars; > // they'll be automatically restored if necessary after Canvas.setBounds() > scrolledComposite.getHorizontalBar().setVisible(false); >@@ -798,16 +1285,140 @@ > } > canvas.setBounds(bounds); > } else { >- scaleFactor = 1.0; >+ scaleFactor = fitAction.getSelect(); // 50, 100, 200, 400 or 800 >+ scaleFactor = scaleFactor / 100; > Rectangle bounds = scrolledComposite.getClientArea(); > if (workImage != null) { > Rectangle imageBounds = workImage.getBounds(); >- bounds.width = imageBounds.width; >- bounds.height = imageBounds.height; >+ bounds.width = (int) Math.round(imageBounds.width * scaleFactor); >+ bounds.height = (int) Math.round(imageBounds.height * scaleFactor); > } > canvas.setBounds(bounds); > } >- setUpGrabPoints(); >+ >+ canvas.redraw(); >+ } >+ >+ private void updateAnnotationHistory() { >+ int[] history; >+ if (historyCheckpoint < historyDrawTool.size()) { >+ history = historyDrawTool.get(historyCheckpoint); >+ while (history[0] < historyMouseEvent.size()) { >+ historyMouseEvent.remove(historyMouseEvent.size() - 1); >+ } >+ while (historyCheckpoint < historyDrawTool.size()) { >+ historyDrawTool.remove(historyDrawTool.size() - 1); >+ } >+ while (historyCheckpoint < historyDrawText.size()) { >+ historyDrawText.remove(historyDrawText.size() - 1); >+ } >+ while (historyCheckpoint < historyDrawFont.size()) { >+ historyDrawFont.remove(historyDrawFont.size() - 1); >+ } >+ redoAction.setEnabled(false); >+ } >+ >+ undoAction.setEnabled(historyCheckpoint > 0); >+ } >+ >+ /** >+ * Draw Annotation with history >+ */ >+ private void drawAnnotationHistory() { >+ workImageGC.drawImage(originalImage, 0, 0); >+ Color backBackground = workImageGC.getBackground(); >+ Color backForeground = workImageGC.getForeground(); >+ int backLineStyle = workImageGC.getLineStyle(); >+ int backLineWidth = workImageGC.getLineWidth(); >+ int[] history; >+ for (int c = 0; c < historyCheckpoint; c++) { >+ history = historyDrawTool.get(c); >+ int toolKind = history[1]; >+ int boldlKind = history[3]; >+ workImageGC.setLineStyle(history[2]); >+ workImageGC.setLineWidth(boldlKind); >+ workImageGC.setForeground(new Color(getShell().getDisplay(), // >+ history[4] >> 16, // >+ (history[4] >> 8) & 0x00ff, // >+ history[4] & 0x00ff)); >+ >+ int h = history[0]; >+ history = historyMouseEvent.get(h); >+ int start_x = history[1]; >+ int start_y = history[2]; >+ for (h++; h < historyMouseEvent.size(); h++) { >+ history = historyMouseEvent.get(h); >+ if (history[0] == SWT.MouseUp) { >+ break; >+ } >+ int x = history[1]; >+ int y = history[2]; >+ if (toolKind == SelectToolAction.DRAW_FREE) { >+ workImageGC.drawLine(start_x, start_y, x, y); >+ start_x = x; >+ start_y = y; >+ } else { >+ if (start_x == x && start_y == y) { >+ workImageGC.drawLine(start_x, start_y, x, y); >+ } else { >+ int rounded; >+ int width = x - start_x; >+ int height = y - start_y; >+ switch (toolKind) { >+ case SelectToolAction.DRAW_LINE: >+ workImageGC.drawLine(start_x, start_y, x, y); >+ break; >+ case SelectToolAction.DRAW_ARROW1: >+ drawArrowLine(start_x, start_y, x, y, false); >+ break; >+ case SelectToolAction.DRAW_ARROW2: >+ drawArrowLine(start_x, start_y, x, y, true); >+ break; >+ case SelectToolAction.DRAW_BOX: >+ workImageGC.drawRectangle(start_x, start_y, width, height); >+ break; >+ case SelectToolAction.DRAW_RBOX: >+ rounded = boldlKind * 8; >+ workImageGC.drawRoundRectangle(start_x, start_y, width, height, rounded, rounded); >+ break; >+ case SelectToolAction.DRAW_OVAL: >+ workImageGC.drawOval(start_x, start_y, width, height); >+ break; >+ case SelectToolAction.DRAW_FILL_BOX: >+ workImageGC.setBackground(workImageGC.getForeground()); >+ workImageGC.fillRectangle(start_x, start_y, width, height); >+ break; >+ case SelectToolAction.DRAW_FILL_RBOX: >+ rounded = boldlKind * 8; >+ workImageGC.setBackground(workImageGC.getForeground()); >+ workImageGC.fillRoundRectangle(start_x, start_y, width, height, rounded, rounded); >+ break; >+ case SelectToolAction.DRAW_FILL_OVAL: >+ workImageGC.setBackground(workImageGC.getForeground()); >+ workImageGC.fillOval(start_x, start_y, width, height); >+ break; >+ case SelectToolAction.DRAW_TEXT: >+ StringBuffer text = historyDrawText.get(c); >+ { >+ Font backFont = workImageGC.getFont(); >+ FontData fontData = new FontData(historyDrawFont.get(c)); >+ workImageGC.setFont(new Font(getShell().getDisplay(), fontData)); >+ workImageGC.setClipping(start_x, start_y, width, height); >+ workImageGC.drawText(text.toString(), start_x, start_y, true); >+ workImageGC.setClipping((Rectangle) null); >+ workImageGC.setFont(backFont); >+ } >+ break; >+ } >+ } >+ } >+ } >+ } >+ workImageGC.setBackground(backBackground); >+ workImageGC.setForeground(backForeground); >+ workImageGC.setLineStyle(backLineStyle); >+ workImageGC.setLineWidth(backLineWidth); >+ > canvas.redraw(); > } > >@@ -818,7 +1429,7 @@ > if (currentSelection == null) { > return; > } >- Rectangle scaledSelection = getScaledSelection(); >+ Rectangle inside = getScaledSelection(); > > // Draw shadow > gc.setBackground(CommonColors.GRAY_MID); >@@ -827,7 +1438,7 @@ > > Region invertedSelection = new Region(); > invertedSelection.add(canvas.getClientArea()); >- invertedSelection.subtract(scaledSelection); >+ invertedSelection.subtract(inside); > gc.setClipping(invertedSelection); > gc.fillRectangle(canvas.getClientArea()); > gc.setClipping((Region) null); >@@ -838,30 +1449,158 @@ > // Draw selection rectangle > gc.setLineStyle(SWT.LINE_SOLID); > gc.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY)); >- gc.drawRectangle(scaledSelection); >+ gc.drawRectangle(inside); > >- // Draw grab points >- gc.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE)); >- gc.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_BLACK)); >- for (GrabPoint point : grabPoints) { >- gc.fillRectangle(point.grabArea); >- gc.drawRectangle(point.grabArea); >- } >+// // Draw grab points >+// gc.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE)); >+// gc.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_BLACK)); >+// for (GrabPoint point : grabPoints) { >+// gc.fillRectangle(point.grabArea); >+// gc.drawRectangle(point.grabArea); >+// } >+ gc.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY)); >+ Rectangle outside = getOutsideSelection(inside); >+ gc.drawRectangle(outside); >+ gc.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY)); >+ gc.fillRectangle(outside.x, outside.y, // >+ SQUARE_SIZE * 6, SQUARE_SIZE * 2); >+ gc.fillRectangle(outside.x + outside.width - SQUARE_SIZE * 6, outside.y, // >+ SQUARE_SIZE * 6, SQUARE_SIZE * 2); >+ gc.fillRectangle(outside.x, outside.y, // >+ SQUARE_SIZE * 2, SQUARE_SIZE * 6); >+ gc.fillRectangle(outside.x + outside.width - SQUARE_SIZE * 2, outside.y, // >+ SQUARE_SIZE * 2, SQUARE_SIZE * 6); >+ gc.fillRectangle(outside.x, outside.y + outside.height - SQUARE_SIZE * 6, // >+ SQUARE_SIZE * 2, SQUARE_SIZE * 6); >+ gc.fillRectangle(outside.x + outside.width - SQUARE_SIZE * 2, outside.y + outside.height - SQUARE_SIZE * 6, // >+ SQUARE_SIZE * 2, SQUARE_SIZE * 6); >+ gc.fillRectangle(outside.x, outside.y + outside.height - SQUARE_SIZE * 2, // >+ SQUARE_SIZE * 6, SQUARE_SIZE * 2); >+ gc.fillRectangle(outside.x + outside.width - SQUARE_SIZE * 6, outside.y + outside.height - SQUARE_SIZE * 2, // >+ SQUARE_SIZE * 6, SQUARE_SIZE * 2); > } > > /** >- * Connects the previous mark point to the new reference point, by drawing a new line >+ * Connects the previous mark point to the new reference point, by drawing a new line, rectangle or oval > */ > private void drawMarkLine(int x, int y) { > if (startPoint != null) { > clearAction.setEnabled(true); >- workImageGC.drawLine(startPoint.x, startPoint.y, x, y); >- startPoint.x = x; >- startPoint.y = y; >+ if (drawToolbar.getSelect() == SelectToolAction.DRAW_FREE) { >+ workImageGC.drawLine(startPoint.x, startPoint.y, x, y); >+ startPoint.x = x; >+ startPoint.y = y; >+ } else { >+ workImageGC.drawImage(previousImage, 0, 0); >+ if (startPoint.x == x && startPoint.y == y) { >+ workImageGC.drawLine(startPoint.x, startPoint.y, x, y); >+ } else { >+ Color backColor; >+ Color markColor; >+ int rounded; >+ int width = x - startPoint.x; >+ int height = y - startPoint.y; >+ switch (drawToolbar.getSelect()) { >+ case SelectToolAction.DRAW_LINE: >+ workImageGC.drawLine(startPoint.x, startPoint.y, x, y); >+ break; >+ case SelectToolAction.DRAW_ARROW1: >+ drawArrowLine(startPoint.x, startPoint.y, x, y, false); >+ break; >+ case SelectToolAction.DRAW_ARROW2: >+ drawArrowLine(startPoint.x, startPoint.y, x, y, true); >+ break; >+ case SelectToolAction.DRAW_BOX: >+ workImageGC.drawRectangle(startPoint.x, startPoint.y, width, height); >+ break; >+ case SelectToolAction.DRAW_RBOX: >+ rounded = boldToolbar.getSelect() * 8; >+ workImageGC.drawRoundRectangle(startPoint.x, startPoint.y, width, height, rounded, rounded); >+ break; >+ case SelectToolAction.DRAW_OVAL: >+ workImageGC.drawOval(startPoint.x, startPoint.y, width, height); >+ break; >+ case SelectToolAction.DRAW_FILL_BOX: >+ backColor = workImageGC.getBackground(); >+ markColor = new Color(getShell().getDisplay(), >+ SelectToolAction.int2rgb(colorToolbar.getSelect())); >+ workImageGC.setBackground(markColor); >+ workImageGC.fillRectangle(startPoint.x, startPoint.y, width, height); >+ workImageGC.setBackground(backColor); >+ break; >+ case SelectToolAction.DRAW_FILL_RBOX: >+ rounded = boldToolbar.getSelect() * 8; >+ backColor = workImageGC.getBackground(); >+ markColor = new Color(getShell().getDisplay(), >+ SelectToolAction.int2rgb(colorToolbar.getSelect())); >+ workImageGC.setBackground(markColor); >+ workImageGC.fillRoundRectangle(startPoint.x, startPoint.y, width, height, rounded, rounded); >+ workImageGC.setBackground(backColor); >+ break; >+ case SelectToolAction.DRAW_FILL_OVAL: >+ backColor = workImageGC.getBackground(); >+ markColor = new Color(getShell().getDisplay(), >+ SelectToolAction.int2rgb(colorToolbar.getSelect())); >+ workImageGC.setBackground(markColor); >+ workImageGC.fillOval(startPoint.x, startPoint.y, width, height); >+ workImageGC.setBackground(backColor); >+ break; >+ case SelectToolAction.DRAW_TEXT: >+ workImageGC.fillRectangle(startPoint.x, startPoint.y, width, height); >+ workImageGC.drawRectangle(startPoint.x, startPoint.y, width, height); >+ break; >+ } >+ } >+ } > canvas.redraw(); > } > } > >+ public void drawArrowLine(int xs, int ys, int xe, int ye, boolean bothsides) { >+ int width = xe - xs, height = ye - ys; >+ int bold = workImageGC.getLineWidth(); >+ int leng = (bold == 8) ? bold * 4 : (bold == 4) ? bold * 6 : (bold == 2) ? bold * 8 : bold * 10; >+ double delta = Math.PI / 6.0; >+ double theta = Math.atan2(height, width); >+ >+ // Draw line >+ if (bothsides) { >+ workImageGC.drawLine( // >+ xs + (int) (leng / 2 * Math.cos(theta)), // >+ ys + (int) (leng / 2 * Math.sin(theta)), // >+ xe - (int) (leng / 2 * Math.cos(theta)), // >+ ye - (int) (leng / 2 * Math.sin(theta))); >+ } else { >+ workImageGC.drawLine( // >+ xs, // >+ ys, // >+ xe - (int) (leng / 2 * Math.cos(theta)), // >+ ye - (int) (leng / 2 * Math.sin(theta))); >+ } >+ >+ // Draw ending side arrow >+ workImageGC.setLineWidth(1); >+ >+ int[] point = { xe, ye, // >+ xe - (int) (leng * Math.cos(theta - delta)), // >+ ye - (int) (leng * Math.sin(theta - delta)), // >+ xe - (int) (leng * Math.cos(theta + delta)), // >+ ye - (int) (leng * Math.sin(theta + delta)) }; >+ workImageGC.fillPolygon(point); >+ >+ // Draw starting side arrow >+ if (bothsides) { >+ int[] point2 = { xs, ys, // >+ xs + (int) (leng * Math.cos(theta - delta)), // >+ ys + (int) (leng * Math.sin(theta - delta)), // >+ xs + (int) (leng * Math.cos(theta + delta)), // >+ ys + (int) (leng * Math.sin(theta + delta)) }; >+ workImageGC.fillPolygon(point2); >+ } >+ >+ workImageGC.setLineWidth(bold); >+ } >+ > private static enum SelectionSide { > > LEFT, RIGHT, TOP, BOTTOM; >@@ -870,26 +1609,6 @@ > > private static final int SQUARE_SIZE = 3; > >- private static class GrabPoint { >- >- public Rectangle grabArea; >- >- public int cursorType; >- >- public Set<SelectionSide> resizableSides; >- >- public static GrabPoint createGrabPoint(int x, int y, int cursorType, Set<SelectionSide> resizableSides) { >- GrabPoint point = new GrabPoint(); >- point.grabArea = new Rectangle(x - SQUARE_SIZE, y - SQUARE_SIZE, SQUARE_SIZE * 2 + 1, SQUARE_SIZE * 2 + 1); >- point.cursorType = cursorType; >- point.resizableSides = resizableSides; >- return point; >- } >- >- } >- >- private final List<GrabPoint> grabPoints = new ArrayList<GrabPoint>(8); >- > /** > * Creates the final screenshot > * >Index: src/org/eclipse/mylyn/internal/provisional/commons/ui/CommonImages.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.commons.ui/src/org/eclipse/mylyn/internal/provisional/commons/ui/CommonImages.java,v >retrieving revision 1.11 >diff -u -r1.11 CommonImages.java >--- src/org/eclipse/mylyn/internal/provisional/commons/ui/CommonImages.java 3 Dec 2008 02:39:31 -0000 1.11 >+++ src/org/eclipse/mylyn/internal/provisional/commons/ui/CommonImages.java 1 May 2009 14:42:28 -0000 >@@ -45,6 +45,8 @@ > > private static final String T_OVR = "ovr16"; //$NON-NLS-1$ > >+ private static final String T_DRAW = "draw16"; //$NON-NLS-1$ >+ > // Priorities > > public static final ImageDescriptor PRIORITY_1 = create(T_OBJ, "priority-1.gif"); //$NON-NLS-1$ >@@ -155,6 +157,32 @@ > > public static final ImageDescriptor EDIT = create(T_TOOL, "edit.gif"); //$NON-NLS-1$ > >+ public static final ImageDescriptor EDIT_FREE = create(T_DRAW, "edit_free.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor EDIT_LINE = create(T_DRAW, "edit_line.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor EDIT_BOX = create(T_DRAW, "edit_box.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor EDIT_RBOX = create(T_DRAW, "edit_rbox.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor EDIT_OVAL = create(T_DRAW, "edit_oval.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor EDIT_FILL_BOX = create(T_DRAW, "edit_fill_box.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor EDIT_FILL_RBOX = create(T_DRAW, "edit_fill_rbox.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor EDIT_FILL_OVAL = create(T_DRAW, "edit_fill_oval.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor EDIT_ARROW1 = create(T_DRAW, "edit_arrow1.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor EDIT_ARROW2 = create(T_DRAW, "edit_arrow2.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor EDIT_TEXT = create(T_TOOL, "font.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor EDIT_UNDO = create(T_TOOL, "undo_edit.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor EDIT_REDO = create(T_TOOL, "redo_edit.gif"); //$NON-NLS-1$ >+ > public static final ImageDescriptor CUT = create(T_TOOL, "cut.gif"); //$NON-NLS-1$ > > public static final ImageDescriptor STATUS_NORMAL = create(T_EVIEW, "status-normal.gif"); //$NON-NLS-1$ >@@ -201,6 +229,34 @@ > > public static final ImageDescriptor FIND = create(T_TOOL, "find.gif"); //$NON-NLS-1$ > >+ public static final ImageDescriptor FILE_OBJ = create(T_TOOL, "file_obj.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor CLIPBOARD_OBJ = create(T_TOOL, "clipboard_obj.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor MINITOR_OBJ = create(T_TOOL, "monitor_obj.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor LINE_SOLD = create(T_DRAW, "line_sold.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor LINE_DOT = create(T_DRAW, "line_dot.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor LINE_DASH = create(T_DRAW, "line_dash.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor LINE_DASH1D = create(T_DRAW, "line_dash1d.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor LINE_DASH2D = create(T_DRAW, "line_dash2d.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor LINE_BOLD1 = create(T_DRAW, "line_bold1.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor LINE_BOLD2 = create(T_DRAW, "line_bold2.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor LINE_BOLD4 = create(T_DRAW, "line_bold4.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor LINE_BOLD8 = create(T_DRAW, "line_bold8.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor SEL_COLOR = create(T_DRAW, "select_color.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor SEL_RECT = create(T_TOOL, "select_rect.gif"); //$NON-NLS-1$ >+ > private static ImageDescriptor create(String prefix, String name) { > try { > return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name)); >Index: src/org/eclipse/mylyn/internal/commons/ui/Messages.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.commons.ui/src/org/eclipse/mylyn/internal/commons/ui/Messages.java,v >retrieving revision 1.2 >diff -u -r1.2 Messages.java >--- src/org/eclipse/mylyn/internal/commons/ui/Messages.java 10 Jan 2009 08:39:37 -0000 1.2 >+++ src/org/eclipse/mylyn/internal/commons/ui/Messages.java 1 May 2009 14:42:27 -0000 >@@ -53,11 +53,17 @@ > > public static String ScreenshotCreationPage_CAPTURE_SCRRENSHOT; > >- public static String ScreenshotCreationPage_Change_pen_color; >- > public static String ScreenshotCreationPage_Clear_all_annotations_made_on_screenshot_image; > >- public static String ScreenshotCreationPage_Clear_Annotations; >+ public static String ScreenshotCreationPage_Clear; >+ >+ public static String ScreenshotCreationPage_Undo; >+ >+ public static String ScreenshotCreationPage_Undo_annotation; >+ >+ public static String ScreenshotCreationPage_Redo; >+ >+ public static String ScreenshotCreationPage_Redo_annotation; > > public static String ScreenshotCreationPage_Crop; > >@@ -70,4 +76,106 @@ > public static String ScreenshotCreationPage_Fit_Image_F; > > public static String ScreenshotCreationPage_NOTE_THAT_YOU_CONTINUTE; >+ >+ public static String SelectToolAction_Font_Bold; >+ >+ public static String SelectToolAction_Font_Italic; >+ >+ public static String SelectToolAction_Font_Name_Size; >+ >+ public static String SelectToolAction_1dot; >+ >+ public static String SelectToolAction_2dots; >+ >+ public static String SelectToolAction_4dots; >+ >+ public static String SelectToolAction_8dots; >+ >+ public static String SelectToolAction_Clipboard; >+ >+ public static String SelectToolAction_Desktop; >+ >+ public static String SelectToolAction_File; >+ >+ public static String SelectToolAction_Rectangle; >+ >+ public static String SelectToolAction_Round_Rectangle; >+ >+ public static String SelectToolAction_Oval; >+ >+ public static String SelectToolAction_Fill_Rectangle; >+ >+ public static String SelectToolAction_Fill_Round_Rectangle; >+ >+ public static String SelectToolAction_Fill_Oval; >+ >+ public static String SelectToolAction_Free; >+ >+ public static String SelectToolAction_Line; >+ >+ public static String SelectToolAction_Single_Side_Arrow; >+ >+ public static String SelectToolAction_Both_Side_Arrow; >+ >+ public static String SelectToolAction_Text; >+ >+ public static String SelectToolAction_Dashed_Line; >+ >+ public static String SelectToolAction_Dashed_Line_1_dot; >+ >+ public static String SelectToolAction_Dashed_Line_2_dots; >+ >+ public static String SelectToolAction_Dotted_Line; >+ >+ public static String SelectToolAction_Solid_Line; >+ >+ public static String SelectToolAction_Fit; >+ >+ public static String SelectToolAction_ZoomHalf; >+ >+ public static String SelectToolAction_Zoom1X; >+ >+ public static String SelectToolAction_Zoom2X; >+ >+ public static String SelectToolAction_Zoom4X; >+ >+ public static String SelectToolAction_Zoom8X; >+ >+ public static String SelectToolAction_Red; >+ >+ public static String SelectToolAction_Dark_Red; >+ >+ public static String SelectToolAction_Green; >+ >+ public static String SelectToolAction_Dark_Green; >+ >+ public static String SelectToolAction_Yellow; >+ >+ public static String SelectToolAction_Dark_Yellow; >+ >+ public static String SelectToolAction_Blue; >+ >+ public static String SelectToolAction_Dark_Blue; >+ >+ public static String SelectToolAction_Magenta; >+ >+ public static String SelectToolAction_Dark_Magenta; >+ >+ public static String SelectToolAction_Cyan; >+ >+ public static String SelectToolAction_Dark_Cyan; >+ >+ public static String SelectToolAction_Gray; >+ >+ public static String SelectToolAction_Dark_Gray; >+ >+ public static String SelectToolAction_White; >+ >+ public static String SelectToolAction_Black; >+ >+ public static String SelectToolAction_Custom_Color; >+ >+ public static String SelectToolAction_Select_Color; >+ >+ public static String SelectToolAction_Selected_Rectangle; > } >Index: src/org/eclipse/mylyn/internal/commons/ui/messages.properties >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.commons.ui/src/org/eclipse/mylyn/internal/commons/ui/messages.properties,v >retrieving revision 1.2 >diff -u -r1.2 messages.properties >--- src/org/eclipse/mylyn/internal/commons/ui/messages.properties 10 Jan 2009 08:39:37 -0000 1.2 >+++ src/org/eclipse/mylyn/internal/commons/ui/messages.properties 1 May 2009 14:42:28 -0000 >@@ -15,15 +15,72 @@ > > ScreenshotCreationPage_After_capturing=After capturing, you can crop the image and make drawings on it. This window will not be captured. > ScreenshotCreationPage_Annotate=&Annotate >-ScreenshotCreationPage_Capture_Desktop=Capture Desktop >-ScreenshotCreationPage_Capture_Desktop_C=&Capture Desktop >+ScreenshotCreationPage_Capture_Desktop=Capture Desktop, Clipboard or File >+ScreenshotCreationPage_Capture_Desktop_C=&Capture > ScreenshotCreationPage_CAPTURE_SCRRENSHOT=Capture Screenshot >-ScreenshotCreationPage_Change_pen_color=Change pen color > ScreenshotCreationPage_Clear_all_annotations_made_on_screenshot_image=Clear all annotations made on screenshot image >-ScreenshotCreationPage_Clear_Annotations=C&lear Annotations >+ScreenshotCreationPage_Clear=C&lear >+ScreenshotCreationPage_Undo=&Undo >+ScreenshotCreationPage_Undo_annotation=Undo annotation >+ScreenshotCreationPage_Redo=Re&do >+ScreenshotCreationPage_Redo_annotation=Redo annotation > ScreenshotCreationPage_Crop=Crop > ScreenshotCreationPage_Crop_R=C&rop > ScreenshotCreationPage_DRAW_ANNOTATION_ON_SCREENSHOT_IMAGE=Draw annotations on screenshot image > ScreenshotCreationPage_Fit_Image=Fit Image >-ScreenshotCreationPage_Fit_Image_F=&Fit Image >+#ScreenshotCreationPage_Fit_Image_F=&Fit Image >+ScreenshotCreationPage_Fit_Image_F=&Fit > ScreenshotCreationPage_NOTE_THAT_YOU_CONTINUTE=Note that you can continue to interact with the workbench in order to set up the screenshot. >+ >+SelectToolAction_Font_Bold=, Bold >+SelectToolAction_Font_Italic=, Italic >+SelectToolAction_Font_Name_Size={0}, {1} pt >+ >+SelectToolAction_1dot=1 dot >+SelectToolAction_2dots=2 dots >+SelectToolAction_4dots=4 dots >+SelectToolAction_8dots=8 dots >+SelectToolAction_Clipboard=Clipboard >+SelectToolAction_Desktop=Desktop >+SelectToolAction_File=File... >+SelectToolAction_Selected_Rectangle=Selected Rectangle >+SelectToolAction_Rectangle=Rectangle >+SelectToolAction_Round_Rectangle=Round Rectangle >+SelectToolAction_Oval=Oval >+SelectToolAction_Fill_Rectangle=Fill Rectangle >+SelectToolAction_Fill_Round_Rectangle=Fill Round Rectangle >+SelectToolAction_Fill_Oval=Fill Oval >+SelectToolAction_Free=Free >+SelectToolAction_Line=Line >+SelectToolAction_Single_Side_Arrow=Single Side Arrow >+SelectToolAction_Both_Side_Arrow=Both Side Arrow >+SelectToolAction_Text=Text >+SelectToolAction_Dashed_Line=Dashed Line >+SelectToolAction_Dashed_Line_1_dot=1 dots Dashed Line >+SelectToolAction_Dashed_Line_2_dots=2 dots Dashed Line >+SelectToolAction_Dotted_Line=Dotted Line >+SelectToolAction_Solid_Line=Solid Line >+SelectToolAction_Fit=Fit >+SelectToolAction_ZoomHalf=50% >+SelectToolAction_Zoom1X=100% >+SelectToolAction_Zoom2X=200% >+SelectToolAction_Zoom4X=400% >+SelectToolAction_Zoom8X=800% >+SelectToolAction_Red=Red >+SelectToolAction_Dark_Red=Dark Red >+SelectToolAction_Green=Green >+SelectToolAction_Dark_Green=Dark Green >+SelectToolAction_Yellow=Yellow >+SelectToolAction_Dark_Yellow=Dark Yellow >+SelectToolAction_Blue=Blue >+SelectToolAction_Dark_Blue=Dark Blue >+SelectToolAction_Magenta=Magenta >+SelectToolAction_Dark_Magenta=Dark Magenta >+SelectToolAction_Cyan=Cyan >+SelectToolAction_Dark_Cyan=Dark Cyan >+SelectToolAction_Gray=Gray >+SelectToolAction_Dark_Gray=Dark Gray >+SelectToolAction_White=White >+SelectToolAction_Black=Black >+SelectToolAction_Custom_Color=Custom Color >+SelectToolAction_Select_Color=Select Color >Index: src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectToolAction.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectToolAction.java >diff -N src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectToolAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectToolAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,592 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Tasktop Technologies and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Hiroyuki Inaba - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.mylyn.internal.provisional.commons.ui; >+ >+import org.eclipse.jface.action.Action; >+import org.eclipse.jface.action.ActionContributionItem; >+import org.eclipse.jface.action.IMenuCreator; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.mylyn.internal.commons.ui.Messages; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.dnd.Clipboard; >+import org.eclipse.swt.dnd.ImageTransfer; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Font; >+import org.eclipse.swt.graphics.FontData; >+import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.ImageData; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.RGB; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.widgets.ColorDialog; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.swt.widgets.FileDialog; >+import org.eclipse.swt.widgets.FontDialog; >+import org.eclipse.swt.widgets.Listener; >+import org.eclipse.swt.widgets.Menu; >+import org.eclipse.swt.widgets.ToolBar; >+import org.eclipse.swt.widgets.ToolItem; >+import org.eclipse.swt.widgets.Widget; >+ >+public class SelectToolAction extends Action implements IMenuCreator { >+ >+ public static final int CAPTURE_DROP_DOWN_MENU = 1; >+ >+ public static final int ZOOM_DROP_DOWN_MENU = 2; >+ >+ public static final int DRAW_TOOLBAR = 3; >+ >+ public static final int LINE_TOOLBAR = 4; >+ >+ public static final int BOLD_TOOLBAR = 5; >+ >+ public static final int COLOR_TOOLBAR = 6; >+ >+ public static final int FONT_TOOLBAR = 7; >+ >+ public SelectToolAction(Composite parent, int tool) { >+ this(parent, "", tool); //$NON-NLS-1$ >+ } >+ >+ public SelectToolAction(String label, int tool) { >+ this(null, label, tool); >+ } >+ >+ public SelectToolAction(Composite parent, String label, int tool) { >+ super(label, AS_DROP_DOWN_MENU); >+ setMenuCreator(this); >+ showMenuAlways = true; >+ this.parent = parent; >+ setToolAction(tool); >+ } >+ >+ private void setToolAction(int tool) { >+ if (tool == CAPTURE_DROP_DOWN_MENU) { >+ selectedItemID = CAPTURE_DESKTOP; >+ initMenu(tool, new ToolActionItem[] { >+ new ToolActionItem(CAPTURE_DESKTOP, Messages.SelectToolAction_Desktop, CommonImages.MINITOR_OBJ), // >+ new ToolActionItem(CAPTURE_CLIPBOARD, Messages.SelectToolAction_Clipboard, >+ CommonImages.CLIPBOARD_OBJ), // >+ new ToolActionItem(CAPTURE_FILE, Messages.SelectToolAction_File, CommonImages.FILE_OBJ), >+ new ToolActionItem(CAPTURE_RECTANGLE, Messages.SelectToolAction_Selected_Rectangle, >+ CommonImages.SEL_RECT) }); >+ return; >+ } >+ >+ if (tool == ZOOM_DROP_DOWN_MENU) { >+ selectedItemID = ZOOM_FIT; >+ initMenu(tool, new ToolActionItem[] { new ToolActionItem(ZOOM_FIT, Messages.SelectToolAction_Fit, null), >+ new ToolActionItem(50, Messages.SelectToolAction_ZoomHalf, null), >+ new ToolActionItem(100, Messages.SelectToolAction_Zoom1X, null), >+ new ToolActionItem(200, Messages.SelectToolAction_Zoom2X, null), >+ new ToolActionItem(400, Messages.SelectToolAction_Zoom4X, null), >+ new ToolActionItem(800, Messages.SelectToolAction_Zoom8X, null) }); >+ return; >+ } >+ >+ if (tool == LINE_TOOLBAR) { >+ selectedItemID = SWT.LINE_SOLID; >+ initBar(tool, new ToolActionItem[] { >+ new ToolActionItem(SWT.LINE_SOLID, Messages.SelectToolAction_Solid_Line, CommonImages.LINE_SOLD), >+ new ToolActionItem(SWT.LINE_DOT, Messages.SelectToolAction_Dotted_Line, CommonImages.LINE_DOT), >+ new ToolActionItem(SWT.LINE_DASH, Messages.SelectToolAction_Dashed_Line, CommonImages.LINE_DASH), >+ new ToolActionItem(SWT.LINE_DASHDOT, Messages.SelectToolAction_Dashed_Line_1_dot, >+ CommonImages.LINE_DASH1D), >+ new ToolActionItem(SWT.LINE_DASHDOTDOT, Messages.SelectToolAction_Dashed_Line_2_dots, >+ CommonImages.LINE_DASH2D) }); >+ return; >+ } >+ >+ if (tool == DRAW_TOOLBAR) { >+ selectedItemID = DRAW_FREE; >+ initBar(tool, >+ new ToolActionItem[] { >+ new ToolActionItem(DRAW_FREE, Messages.SelectToolAction_Free, CommonImages.EDIT_FREE), >+ new ToolActionItem(DRAW_LINE, Messages.SelectToolAction_Line, CommonImages.EDIT_LINE), >+ new ToolActionItem(DRAW_ARROW1, Messages.SelectToolAction_Single_Side_Arrow, >+ CommonImages.EDIT_ARROW1), >+ new ToolActionItem(DRAW_ARROW2, Messages.SelectToolAction_Both_Side_Arrow, >+ CommonImages.EDIT_ARROW2), >+ new ToolActionItem(DRAW_BOX, Messages.SelectToolAction_Rectangle, CommonImages.EDIT_BOX), >+ new ToolActionItem(DRAW_RBOX, Messages.SelectToolAction_Round_Rectangle, >+ CommonImages.EDIT_RBOX), >+ new ToolActionItem(DRAW_OVAL, Messages.SelectToolAction_Oval, CommonImages.EDIT_OVAL), >+ new ToolActionItem(DRAW_FILL_BOX, Messages.SelectToolAction_Fill_Rectangle, >+ CommonImages.EDIT_FILL_BOX), >+ new ToolActionItem(DRAW_FILL_RBOX, Messages.SelectToolAction_Fill_Round_Rectangle, >+ CommonImages.EDIT_FILL_RBOX), >+ new ToolActionItem(DRAW_FILL_OVAL, Messages.SelectToolAction_Fill_Oval, >+ CommonImages.EDIT_FILL_OVAL), >+ new ToolActionItem(DRAW_TEXT, Messages.SelectToolAction_Text, CommonImages.EDIT_TEXT) }); >+ return; >+ } >+ >+ if (tool == BOLD_TOOLBAR) { >+ selectedItemID = 4; >+ initBar(tool, new ToolActionItem[] { >+ new ToolActionItem(1, Messages.SelectToolAction_1dot, CommonImages.LINE_BOLD1), >+ new ToolActionItem(2, Messages.SelectToolAction_2dots, CommonImages.LINE_BOLD2), >+ new ToolActionItem(4, Messages.SelectToolAction_4dots, CommonImages.LINE_BOLD4), >+ new ToolActionItem(8, Messages.SelectToolAction_8dots, CommonImages.LINE_BOLD8) }); >+ return; >+ } >+ >+ if (tool == COLOR_TOOLBAR) { >+ intgerCustom = rgb2int(255, 85, 85); >+ selectedItemID = intgerCustom; >+ initColor(tool, new ToolActionItem[] { >+ new ToolActionItem(SWT.COLOR_RED, Messages.SelectToolAction_Red, null), >+ new ToolActionItem(SWT.COLOR_DARK_RED, Messages.SelectToolAction_Dark_Red, null), >+ new ToolActionItem(SWT.COLOR_GREEN, Messages.SelectToolAction_Green, null), >+ new ToolActionItem(SWT.COLOR_DARK_GREEN, Messages.SelectToolAction_Dark_Green, null), >+ new ToolActionItem(SWT.COLOR_YELLOW, Messages.SelectToolAction_Yellow, null), >+ new ToolActionItem(SWT.COLOR_DARK_YELLOW, Messages.SelectToolAction_Dark_Yellow, null), >+ new ToolActionItem(SWT.COLOR_BLUE, Messages.SelectToolAction_Blue, null), >+ new ToolActionItem(SWT.COLOR_DARK_BLUE, Messages.SelectToolAction_Dark_Blue, null), >+ new ToolActionItem(SWT.COLOR_MAGENTA, Messages.SelectToolAction_Magenta, null), >+ new ToolActionItem(SWT.COLOR_DARK_MAGENTA, Messages.SelectToolAction_Dark_Magenta, null), >+ new ToolActionItem(SWT.COLOR_CYAN, Messages.SelectToolAction_Cyan, null), >+ new ToolActionItem(SWT.COLOR_DARK_CYAN, Messages.SelectToolAction_Dark_Cyan, null), >+ new ToolActionItem(SWT.COLOR_GRAY, Messages.SelectToolAction_Gray, null), >+ new ToolActionItem(SWT.COLOR_DARK_GRAY, Messages.SelectToolAction_Dark_Gray, null), >+ new ToolActionItem(SWT.COLOR_WHITE, Messages.SelectToolAction_White, null), >+ new ToolActionItem(SWT.COLOR_BLACK, Messages.SelectToolAction_Black, null), >+ new ToolActionItem(intgerCustom, Messages.SelectToolAction_Custom_Color, null), >+ new ToolActionItem(0, Messages.SelectToolAction_Select_Color, CommonImages.SEL_COLOR) }); >+ return; >+ } >+ >+ if (tool == FONT_TOOLBAR) { >+ FontData fontData = parent.getShell().getFont().getFontData()[0]; >+ stringCustom = fontData.toString(); >+ intgerCustom = rgb2int(255, 0, 0); >+ selectedItemID = intgerCustom; >+ initFont(tool, new ToolActionItem[] { new ToolActionItem(0, "", null) }); //$NON-NLS-1$ >+ return; >+ } >+ } >+ >+ private void initBar(int tool, ToolActionItem[] items) { >+ this.items = items; >+ setId(tool + ""); //$NON-NLS-1$ >+ toolBar = new ToolBar(parent, SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT); >+ if (items != null) { >+ Listener listener = new Listener() { >+ public void handleEvent(Event event) { >+ selectItem(((ToolItem) (event.widget)).getToolTipText(), null); >+ } >+ }; >+ for (ToolActionItem actionItem : items) { >+ ToolItem item = new ToolItem(toolBar, SWT.RADIO); >+ item.setImage(actionItem.image.createImage()); >+ item.setToolTipText(actionItem.label); >+ if (actionItem.id == selectedItemID) { >+ item.setSelection(true); >+ } >+ item.addListener(SWT.Selection, listener); >+ } >+ new ToolItem(toolBar, SWT.SEPARATOR); >+ } >+ } >+ >+ private void initFont(int tool, ToolActionItem[] items) { >+ this.items = items; >+ setId(tool + ""); //$NON-NLS-1$ >+ toolBar = new ToolBar(parent, SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT); >+ if (items != null) { >+ Listener listener = new Listener() { >+ public void handleEvent(Event event) { >+ ToolItem item = (ToolItem) (event.widget); >+ FontData fontData = new FontData(stringCustom); >+ FontDialog fontWindow = new FontDialog(parent.getShell()); >+ fontWindow.setFontList(new FontData[] { fontData }); >+ fontWindow.setRGB(int2rgb(intgerCustom)); >+ fontData = fontWindow.open(); >+ if (fontData != null) { >+ intgerCustom = rgb2int(fontWindow.getRGB()); >+ stringCustom = fontData.toString(); >+ item.setToolTipText(font2string(fontData)); >+ item.setImage(createFontImage(fontData, int2rgb(intgerCustom))); >+ } >+ } >+ }; >+ ToolItem item = new ToolItem(toolBar, SWT.PUSH); >+ FontData fontData = new FontData(stringCustom); >+ item.setToolTipText(font2string(fontData)); >+ item.setImage(createFontImage(fontData, int2rgb(intgerCustom))); >+ item.addListener(SWT.Selection, listener); >+ new ToolItem(toolBar, SWT.SEPARATOR); >+ } >+ } >+ >+ private void initColor(int tool, ToolActionItem[] items) { >+ this.items = items; >+ setId(tool + ""); //$NON-NLS-1$ >+ toolBar = new ToolBar(parent, SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT); >+ if (items != null) { >+ Listener listener = new Listener() { >+ public void handleEvent(Event event) { >+ String text = ((ToolItem) (event.widget)).getToolTipText(); >+ if (text.equals(Messages.SelectToolAction_Select_Color)) { >+ ToolItem[] items = ((ToolItem) (event.widget)).getParent().getItems(); >+ ColorDialog colorWindow = new ColorDialog(parent.getShell()); >+ colorWindow.setRGB(int2rgb(selectedItemID)); >+ RGB rgb = colorWindow.open(); >+ if (rgb != null) { >+ selectedItemID = rgb2int(rgb); >+ Image image = createColorImage(rgb); >+ items[items.length - 3].setImage(image); >+ } >+ items[items.length - 3].setSelection(true); >+ items[items.length - 2].setSelection(false); >+ } else { >+ selectItem(text, null); >+ } >+ } >+ }; >+ Display display = parent.getDisplay(); >+ for (ToolActionItem actionItem : items) { >+ ToolItem item = new ToolItem(toolBar, SWT.RADIO); >+ if (actionItem.image == null) { >+ Color color = null; >+ if (actionItem.label.equals(Messages.SelectToolAction_Custom_Color)) { >+ color = new Color(display, int2rgb(actionItem.id)); >+ } else { >+ color = display.getSystemColor(actionItem.id); >+ actionItem.id = rgb2int(color.getRGB()); >+ } >+ Image image = createColorImage(int2rgb(actionItem.id)); >+ item.setImage(image); >+ } else { >+ item.setImage(actionItem.image.createImage()); >+ } >+ item.setToolTipText(actionItem.label); >+ if (actionItem.id == selectedItemID) { >+ item.setSelection(true); >+ } >+ item.addListener(SWT.Selection, listener); >+ } >+ new ToolItem(toolBar, SWT.SEPARATOR); >+ } >+ } >+ >+ private Image createColorImage(RGB rgb) { >+ Display display = parent.getDisplay(); >+ Color DARK_GRAY = display.getSystemColor(SWT.COLOR_DARK_GRAY); >+ int x = 16, y = 16; >+ Image image = new Image(display, x, y); >+ GC gc = new GC(image); >+ gc.setForeground(DARK_GRAY); >+ gc.setBackground(new Color(display, rgb)); >+ gc.fillRectangle(0, 0, x, y); >+ gc.drawRectangle(0, 0, x - 1, y - 1); >+ gc.dispose(); >+ return image; >+ } >+ >+ private Image createFontImage(FontData fontData, RGB rgb) { >+ Display display = parent.getDisplay(); >+ Color DARK_GRAY = display.getSystemColor(SWT.COLOR_DARK_GRAY); >+ Color ButtonFace = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); >+ int x = 300, y = 16; >+ Image image = new Image(display, x, y); >+ GC gc = new GC(image); >+ gc.setBackground(ButtonFace); >+ gc.fillRectangle(0, 0, x, y); >+ gc.setForeground(DARK_GRAY); >+ gc.drawRectangle(0, 0, x - 1, y - 1); >+ String label = font2string(fontData); >+ fontData.height = 8; >+ fontData.setStyle(fontData.getStyle() & (~SWT.BOLD)); >+ gc.setFont(new Font(display, fontData)); >+ gc.setForeground(new Color(display, rgb)); >+ Point sz = gc.textExtent(label); >+ gc.drawText(label, (x - sz.x) / 2, (y - sz.y) / 2, true); >+ gc.dispose(); >+ return image; >+ } >+ >+ private void initMenu(int tool, ToolActionItem[] items) { >+ this.items = items; >+ setId(tool + ""); //$NON-NLS-1$ >+ if (items != null) { >+ setImageDescriptor(items[0].image); >+ setToolTipText(items[0].label); >+ selectedItemID = items[0].id; >+ } >+ } >+ >+ private class ToolActionItem { >+ int id; >+ >+ String label; >+ >+ ImageDescriptor image; >+ >+ ToolActionItem(int id, String label, ImageDescriptor image) { >+ this.id = id; >+ this.label = label; >+ this.image = image; >+ } >+ } >+ >+ private ToolActionItem[] items; >+ >+ private int selectedItemID; >+ >+ private ToolBar toolBar; >+ >+ private Menu dropDownMenu; >+ >+ private int intgerCustom; >+ >+ private String stringCustom; >+ >+ private boolean showMenuAlways; >+ >+ public boolean isShowMenuAlways() { >+ return showMenuAlways; >+ } >+ >+ public void setShowMenuAlways(boolean showMenuAlways) { >+ this.showMenuAlways = showMenuAlways; >+ } >+ >+ @Override >+ public void runWithEvent(Event event) { >+ if (showMenuAlways) { >+ IMenuCreator mc = getMenuCreator(); >+ if (mc != null) { >+ Widget item = event.widget; >+ ToolItem ti = (ToolItem) item; >+ Menu m = mc.getMenu(ti.getParent()); >+ if (m != null) { >+ // position the menu below the drop down item >+ Rectangle itemBounds = ti.getBounds(); >+ Point point = ti.getParent().toDisplay(itemBounds.x, itemBounds.y + itemBounds.height); >+ m.setLocation(point.x, point.y); // waiting for SWT >+ m.setVisible(true); >+ return; // we don't fire the action >+ } >+ } >+ } >+ super.runWithEvent(event); >+ } >+ >+ public static final int ZOOM_FIT = 0; >+ >+ public static final int DRAW_FREE = 0; >+ >+ public static final int DRAW_LINE = 1; >+ >+ public static final int DRAW_ARROW1 = 2; >+ >+ public static final int DRAW_ARROW2 = 3; >+ >+ public static final int DRAW_BOX = 10; >+ >+ public static final int DRAW_RBOX = 11; >+ >+ public static final int DRAW_FILL_BOX = 12; >+ >+ public static final int DRAW_FILL_RBOX = 13; >+ >+ public static final int DRAW_OVAL = 20; >+ >+ public static final int DRAW_FILL_OVAL = 21; >+ >+ public static final int DRAW_TEXT = 30; >+ >+ public static final int CAPTURE_DESKTOP = 0; >+ >+ public static final int CAPTURE_CLIPBOARD = 1; >+ >+ public static final int CAPTURE_FILE = 2; >+ >+ public static final int CAPTURE_RECTANGLE = 3; >+ >+ public int getSelect() { >+ return selectedItemID; >+ } >+ >+ public int getIntgerCustom() { >+ return intgerCustom; >+ } >+ >+ public String getStringCustom() { >+ return stringCustom; >+ } >+ >+ protected void selectItem(String label, ImageDescriptor image) { >+ for (ToolActionItem actionItem : items) { >+ if (actionItem.label.equals(label)) { >+ selectedItemID = actionItem.id; >+ if (getId().equals(CAPTURE_DROP_DOWN_MENU + "")) { //$NON-NLS-1$ >+ if (selectedItemID == CAPTURE_FILE) { >+ FileDialog dialog = new FileDialog(parent.getShell()); >+ dialog.setFileName(filename); >+ dialog.setFilterExtensions(new String[] { "*.bmp;*.jpg;*.png", "*.*" }); //$NON-NLS-1$ //$NON-NLS-2$ >+ String result = dialog.open(); >+ if (result != null && result.length() > 0) { >+ filename = result; >+ run(); >+ } >+ } else { >+ run(); >+ } >+ selectedItemID = CAPTURE_DESKTOP; >+ } else { >+ setToolTipText(label); >+ if (image != null) { >+ setImageDescriptor(image); >+ } >+ run(); >+ } >+ break; >+ } >+ } >+ } >+ >+ private void addActionsToMenu() { >+ for (ToolActionItem actionItem : items) { >+ Action action = new Action() { >+ @Override >+ public void run() { >+ selectItem(getText(), getImageDescriptor()); >+ } >+ }; >+ action.setText(actionItem.label); >+ if (actionItem.image != null) { >+ action.setImageDescriptor(actionItem.image); >+ } >+ updateAction(action, actionItem.id); >+ ActionContributionItem contributionItem = new ActionContributionItem(action); >+ contributionItem.fill(dropDownMenu, -1); >+ } >+ } >+ >+ private void updateAction(Action action, int id) { >+ action.setChecked(id == selectedItemID); >+ if (getId().equals(CAPTURE_DROP_DOWN_MENU + "")) { //$NON-NLS-1$ >+ if (id == CAPTURE_CLIPBOARD) { >+ action.setEnabled(existImageOnClipboard()); >+ } else if (id == CAPTURE_RECTANGLE) { >+ action.setEnabled(isEnableRectangle()); >+ } >+ } >+ } >+ >+ protected boolean isEnableRectangle() { >+ return false; >+ } >+ >+ public void dispose() { >+ if (toolBar != null) { >+ toolBar.dispose(); >+ toolBar = null; >+ } >+ if (dropDownMenu != null) { >+ dropDownMenu.dispose(); >+ dropDownMenu = null; >+ } >+ } >+ >+ public Menu getMenu(Control parent) { >+ if (dropDownMenu != null) { >+ dropDownMenu.dispose(); >+ } >+ dropDownMenu = new Menu(parent); >+ addActionsToMenu(); >+ return dropDownMenu; >+ } >+ >+ public Menu getMenu(Menu parent) { >+ if (dropDownMenu != null) { >+ dropDownMenu.dispose(); >+ } >+ dropDownMenu = new Menu(parent); >+ addActionsToMenu(); >+ return dropDownMenu; >+ } >+ >+ private final Composite parent; >+ >+ private String filename; >+ >+ public Image getFileImage() { >+ try { >+ Image image = new Image(parent.getShell().getDisplay(), filename); >+ return image; >+ } catch (Exception e) { >+ // None >+ } >+ return null; >+ } >+ >+ public Image getClipboardImage() { >+ try { >+ Clipboard clipboard = new Clipboard(parent.getShell().getDisplay()); >+ ImageTransfer imageTransfer = ImageTransfer.getInstance(); >+ Object data = clipboard.getContents(imageTransfer); >+ if (data instanceof ImageData) { >+ Image image = new Image(parent.getShell().getDisplay(), (ImageData) data); >+ return image; >+ } >+ } catch (Exception e) { >+ // None >+ } >+ return null; >+ } >+ >+ private boolean existImageOnClipboard() { >+ try { >+ Clipboard clipboard = new Clipboard(parent.getShell().getDisplay()); >+ ImageTransfer imageTransfer = ImageTransfer.getInstance(); >+ Object data = clipboard.getContents(imageTransfer); >+ if (data instanceof ImageData) { >+ return true; >+ } >+ } catch (Exception e) { >+ // None >+ } >+ return false; >+ } >+ >+ public static int rgb2int(RGB rgb) { >+ return rgb2int(rgb.red, rgb.green, rgb.blue); >+ } >+ >+ public static int rgb2int(int r, int g, int b) { >+ return (r << 16) + (g << 8) + b; >+ } >+ >+ public static RGB int2rgb(int rgb) { >+ return new RGB(rgb >> 16, (rgb >> 8) & 0x00ff, rgb & 0x00ff); >+ } >+ >+ private String font2string(FontData fontData) { >+ String info = NLS.bind(Messages.SelectToolAction_Font_Name_Size, // >+ new Object[] { fontData.getName(), fontData.getHeight() + "" }); //$NON-NLS-1$ >+ int style = fontData.getStyle(); >+ if ((style & SWT.BOLD) != 0) { >+ info = info + Messages.SelectToolAction_Font_Bold; >+ } >+ if ((style & SWT.ITALIC) != 0) { >+ info = info + Messages.SelectToolAction_Font_Italic; >+ } >+ return info; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 266123
:
126712
|
126835
|
126836
|
127074
|
127102
|
127103
|
127110
|
127892
|
127914
|
127915
|
128171
|
134062
|
134063
|
134067
|
134078
|
134195
|
134984
|
135048
|
135049