|
Lines 32-39
Link Here
|
| 32 |
import org.eclipse.jface.layout.GridDataFactory; |
32 |
import org.eclipse.jface.layout.GridDataFactory; |
| 33 |
import org.eclipse.jface.resource.ImageDescriptor; |
33 |
import org.eclipse.jface.resource.ImageDescriptor; |
| 34 |
import org.eclipse.jface.wizard.WizardPage; |
34 |
import org.eclipse.jface.wizard.WizardPage; |
| 35 |
import org.eclipse.mylyn.internal.commons.ui.ColorSelectionWindow; |
|
|
| 36 |
import org.eclipse.mylyn.internal.commons.ui.Messages; |
35 |
import org.eclipse.mylyn.internal.commons.ui.Messages; |
|
|
36 |
import org.eclipse.osgi.util.NLS; |
| 37 |
import org.eclipse.swt.SWT; |
37 |
import org.eclipse.swt.SWT; |
| 38 |
import org.eclipse.swt.custom.ScrolledComposite; |
38 |
import org.eclipse.swt.custom.ScrolledComposite; |
| 39 |
import org.eclipse.swt.custom.ViewForm; |
39 |
import org.eclipse.swt.custom.ViewForm; |
|
Lines 46-51
Link Here
|
| 46 |
import org.eclipse.swt.events.PaintListener; |
46 |
import org.eclipse.swt.events.PaintListener; |
| 47 |
import org.eclipse.swt.graphics.Color; |
47 |
import org.eclipse.swt.graphics.Color; |
| 48 |
import org.eclipse.swt.graphics.Cursor; |
48 |
import org.eclipse.swt.graphics.Cursor; |
|
|
49 |
import org.eclipse.swt.graphics.Font; |
| 50 |
import org.eclipse.swt.graphics.FontData; |
| 49 |
import org.eclipse.swt.graphics.GC; |
51 |
import org.eclipse.swt.graphics.GC; |
| 50 |
import org.eclipse.swt.graphics.Image; |
52 |
import org.eclipse.swt.graphics.Image; |
| 51 |
import org.eclipse.swt.graphics.Point; |
53 |
import org.eclipse.swt.graphics.Point; |
|
Lines 53-63
Link Here
|
| 53 |
import org.eclipse.swt.graphics.Rectangle; |
55 |
import org.eclipse.swt.graphics.Rectangle; |
| 54 |
import org.eclipse.swt.graphics.Region; |
56 |
import org.eclipse.swt.graphics.Region; |
| 55 |
import org.eclipse.swt.widgets.Canvas; |
57 |
import org.eclipse.swt.widgets.Canvas; |
|
|
58 |
import org.eclipse.swt.widgets.ColorDialog; |
| 56 |
import org.eclipse.swt.widgets.Composite; |
59 |
import org.eclipse.swt.widgets.Composite; |
| 57 |
import org.eclipse.swt.widgets.Display; |
60 |
import org.eclipse.swt.widgets.Display; |
| 58 |
import org.eclipse.swt.widgets.Event; |
61 |
import org.eclipse.swt.widgets.Event; |
|
|
62 |
import org.eclipse.swt.widgets.FontDialog; |
| 63 |
import org.eclipse.swt.widgets.Listener; |
| 59 |
import org.eclipse.swt.widgets.Shell; |
64 |
import org.eclipse.swt.widgets.Shell; |
| 60 |
import org.eclipse.swt.widgets.ToolItem; |
65 |
import org.eclipse.swt.widgets.Text; |
| 61 |
import org.eclipse.ui.progress.UIJob; |
66 |
import org.eclipse.ui.progress.UIJob; |
| 62 |
|
67 |
|
| 63 |
/** |
68 |
/** |
|
Lines 71-84
Link Here
|
| 71 |
*/ |
76 |
*/ |
| 72 |
public class ScreenshotCreationPage extends WizardPage implements IImageCreator { |
77 |
public class ScreenshotCreationPage extends WizardPage implements IImageCreator { |
| 73 |
|
78 |
|
| 74 |
private IAction captureAction; |
79 |
private SelectCaptureAction captureAction; |
| 75 |
|
80 |
|
| 76 |
private IAction fitAction; |
81 |
private SelectZoomToolAction fitAction; |
| 77 |
|
82 |
|
| 78 |
private IAction cropAction; |
83 |
private IAction cropAction; |
| 79 |
|
84 |
|
| 80 |
private IAction markAction; |
85 |
private IAction markAction; |
| 81 |
|
86 |
|
|
|
87 |
private SelectDrawToolAction toolAction; |
| 88 |
|
| 89 |
private SelectLineToolAction lineAction; |
| 90 |
|
| 91 |
private SelectBoldToolAction boldAction; |
| 92 |
|
| 93 |
private IAction fontAction; |
| 94 |
|
| 95 |
private Font markFont; |
| 96 |
|
| 97 |
private Color markFontColor; |
| 98 |
|
| 82 |
private IAction colorAction; |
99 |
private IAction colorAction; |
| 83 |
|
100 |
|
| 84 |
private Image colorIcon; |
101 |
private Image colorIcon; |
|
Lines 87-92
Link Here
|
| 87 |
|
104 |
|
| 88 |
private IAction clearAction; |
105 |
private IAction clearAction; |
| 89 |
|
106 |
|
|
|
107 |
private IAction undoAction; |
| 108 |
|
| 109 |
private IAction redoAction; |
| 110 |
|
| 90 |
private boolean imageDirty; |
111 |
private boolean imageDirty; |
| 91 |
|
112 |
|
| 92 |
/** |
113 |
/** |
|
Lines 99-104
Link Here
|
| 99 |
*/ |
120 |
*/ |
| 100 |
private Image workImage; |
121 |
private Image workImage; |
| 101 |
|
122 |
|
|
|
123 |
private Image previousImage; |
| 124 |
|
| 102 |
/** |
125 |
/** |
| 103 |
* Used to draw into {@link #workImage} |
126 |
* Used to draw into {@link #workImage} |
| 104 |
*/ |
127 |
*/ |
|
Lines 155-160
Link Here
|
| 155 |
*/ |
178 |
*/ |
| 156 |
private EditorAction currentAction = EditorAction.CROPPING; |
179 |
private EditorAction currentAction = EditorAction.CROPPING; |
| 157 |
|
180 |
|
|
|
181 |
private boolean isFirstCapture = true; |
| 182 |
|
| 183 |
/** |
| 184 |
* Mouse event history. Entry is [0] MouseDown/MouseMove/MouseUp, [1] x, [2] y |
| 185 |
*/ |
| 186 |
private Text textArea; |
| 187 |
|
| 188 |
/** |
| 189 |
* Mouse event history. Entry is [0] MouseDown/MouseMove/MouseUp, [1] x, [2] y |
| 190 |
*/ |
| 191 |
private List<int[]> historyMouseEvent = new ArrayList<int[]>(); |
| 192 |
|
| 193 |
/** |
| 194 |
* Draw tool history. Entry is [0] drawHistory index, [1] FREE/LINE/BOX/OVAL, [2] Line type, [3] Bold, [4] R/G/B |
| 195 |
*/ |
| 196 |
private List<int[]> historyDrawTool = new ArrayList<int[]>(); |
| 197 |
|
| 198 |
private List<StringBuffer> historyDrawText = new ArrayList<StringBuffer>(); |
| 199 |
|
| 200 |
private List<String> historyDrawFont = new ArrayList<String>(); |
| 201 |
|
| 202 |
private int historyCheckpoint = 0; |
| 203 |
|
| 204 |
// MouseDown [1, x, y], MouseMove [2, x, y], MouseUp [0, x, y] |
| 205 |
|
| 158 |
public ScreenshotCreationPage() { |
206 |
public ScreenshotCreationPage() { |
| 159 |
super("ScreenShotAttachment"); //$NON-NLS-1$ |
207 |
super("ScreenShotAttachment"); //$NON-NLS-1$ |
| 160 |
setTitle(Messages.ScreenshotCreationPage_CAPTURE_SCRRENSHOT); |
208 |
setTitle(Messages.ScreenshotCreationPage_CAPTURE_SCRRENSHOT); |
|
Lines 173-185
Link Here
|
| 173 |
|
221 |
|
| 174 |
// TODO: need disabled versions of all toolbar icons |
222 |
// TODO: need disabled versions of all toolbar icons |
| 175 |
ToolBarManager tbm = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT); |
223 |
ToolBarManager tbm = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT); |
| 176 |
captureAction = new Action(Messages.ScreenshotCreationPage_Capture_Desktop_C, IAction.AS_PUSH_BUTTON) { |
|
|
| 177 |
|
224 |
|
| 178 |
private boolean isFirstCapture = true; |
225 |
captureAction = new SelectCaptureAction(getShell(), Messages.ScreenshotCreationPage_Capture_Desktop_C) { |
| 179 |
|
226 |
|
| 180 |
@Override |
227 |
@Override |
| 181 |
public void run() { |
228 |
public void run() { |
| 182 |
captureScreenshotContent(); |
229 |
if (captureAction.getKind() == SelectCaptureAction.CAPTURE) { |
|
|
230 |
captureScreenshotContent(); |
| 231 |
} else { |
| 232 |
captureScreenshotContent(captureAction.getScreenshotImage()); |
| 233 |
} |
| 234 |
captureAction.resetKind(); |
| 183 |
setErrorMessage(null); |
235 |
setErrorMessage(null); |
| 184 |
if (isFirstCapture) { |
236 |
if (isFirstCapture) { |
| 185 |
isFirstCapture = false; |
237 |
isFirstCapture = false; |
|
Lines 189-199
Link Here
|
| 189 |
markAction.setEnabled(true); |
241 |
markAction.setEnabled(true); |
| 190 |
clearAction.setEnabled(false); |
242 |
clearAction.setEnabled(false); |
| 191 |
} |
243 |
} |
|
|
244 |
|
| 245 |
historyMouseEvent = new ArrayList<int[]>(); |
| 246 |
historyDrawTool = new ArrayList<int[]>(); |
| 247 |
historyDrawText = new ArrayList<StringBuffer>(); |
| 248 |
historyDrawFont = new ArrayList<String>(); |
| 249 |
historyCheckpoint = 0; |
| 250 |
undoAction.setEnabled(false); |
| 251 |
redoAction.setEnabled(false); |
| 192 |
} |
252 |
} |
| 193 |
|
253 |
|
| 194 |
}; |
254 |
}; |
| 195 |
captureAction.setToolTipText(Messages.ScreenshotCreationPage_Capture_Desktop); |
255 |
captureAction.setToolTipText(Messages.ScreenshotCreationPage_Capture_Desktop); |
| 196 |
captureAction.setImageDescriptor(ImageDescriptor.createFromImage(CommonImages.getImage(CommonImages.IMAGE_CAPTURE))); |
256 |
captureAction.setImageDescriptor(ImageDescriptor.createFromImage(CommonImages.getImage(CommonImages.IMAGE_CAPTURE))); |
|
|
257 |
captureAction.setShowMenuAlways(false); |
| 197 |
|
258 |
|
| 198 |
// captureDelayedButton = new Button(buttonsComposite, SWT.PUSH); |
259 |
// captureDelayedButton = new Button(buttonsComposite, SWT.PUSH); |
| 199 |
// final String captureIn = "Capture in "; |
260 |
// final String captureIn = "Capture in "; |
|
Lines 228-234
Link Here
|
| 228 |
// } |
289 |
// } |
| 229 |
// }); |
290 |
// }); |
| 230 |
|
291 |
|
| 231 |
fitAction = new Action("", IAction.AS_CHECK_BOX) { //$NON-NLS-1$ |
292 |
fitAction = new SelectZoomToolAction() { |
| 232 |
@Override |
293 |
@Override |
| 233 |
public void run() { |
294 |
public void run() { |
| 234 |
refreshCanvasSize(); |
295 |
refreshCanvasSize(); |
|
Lines 237-243
Link Here
|
| 237 |
fitAction.setToolTipText(Messages.ScreenshotCreationPage_Fit_Image); |
298 |
fitAction.setToolTipText(Messages.ScreenshotCreationPage_Fit_Image); |
| 238 |
fitAction.setText(Messages.ScreenshotCreationPage_Fit_Image_F); |
299 |
fitAction.setText(Messages.ScreenshotCreationPage_Fit_Image_F); |
| 239 |
fitAction.setImageDescriptor(ImageDescriptor.createFromImage(CommonImages.getImage(CommonImages.IMAGE_FIT))); |
300 |
fitAction.setImageDescriptor(ImageDescriptor.createFromImage(CommonImages.getImage(CommonImages.IMAGE_FIT))); |
| 240 |
fitAction.setChecked(true); |
301 |
//fitAction.setChecked(true); |
| 241 |
fitAction.setEnabled(false); |
302 |
fitAction.setEnabled(false); |
| 242 |
|
303 |
|
| 243 |
cropAction = new Action(Messages.ScreenshotCreationPage_Crop_R, IAction.AS_RADIO_BUTTON) { |
304 |
cropAction = new Action(Messages.ScreenshotCreationPage_Crop_R, IAction.AS_RADIO_BUTTON) { |
|
Lines 246-252
Link Here
|
| 246 |
currentAction = EditorAction.CROPPING; |
307 |
currentAction = EditorAction.CROPPING; |
| 247 |
cropAction.setChecked(true); |
308 |
cropAction.setChecked(true); |
| 248 |
markAction.setChecked(false); |
309 |
markAction.setChecked(false); |
|
|
310 |
toolAction.setEnabled(false); |
| 311 |
lineAction.setEnabled(false); |
| 312 |
boldAction.setEnabled(false); |
| 313 |
fontAction.setEnabled(false); |
| 249 |
colorAction.setEnabled(false); |
314 |
colorAction.setEnabled(false); |
|
|
315 |
undoAction.setEnabled(false); |
| 316 |
redoAction.setEnabled(false); |
| 250 |
canvas.redraw(); |
317 |
canvas.redraw(); |
| 251 |
} |
318 |
} |
| 252 |
}; |
319 |
}; |
|
Lines 260-266
Link Here
|
| 260 |
currentAction = EditorAction.MARKING; |
327 |
currentAction = EditorAction.MARKING; |
| 261 |
cropAction.setChecked(false); |
328 |
cropAction.setChecked(false); |
| 262 |
markAction.setChecked(true); |
329 |
markAction.setChecked(true); |
|
|
330 |
toolAction.setEnabled(true); |
| 331 |
lineAction.setEnabled(true); |
| 332 |
boldAction.setEnabled(true); |
| 333 |
fontAction.setEnabled(toolAction.getKind() == SelectDrawToolAction.TEXT); |
| 263 |
colorAction.setEnabled(true); |
334 |
colorAction.setEnabled(true); |
|
|
335 |
undoAction.setEnabled(false); |
| 336 |
redoAction.setEnabled(false); |
| 264 |
canvas.redraw(); |
337 |
canvas.redraw(); |
| 265 |
} |
338 |
} |
| 266 |
}; |
339 |
}; |
|
Lines 269-293
Link Here
|
| 269 |
// markAction.setDisabledImageDescriptor(ImageDescriptor.createFromFile(getClass(), "mark_disabled.gif")); |
342 |
// markAction.setDisabledImageDescriptor(ImageDescriptor.createFromFile(getClass(), "mark_disabled.gif")); |
| 270 |
markAction.setEnabled(false); |
343 |
markAction.setEnabled(false); |
| 271 |
|
344 |
|
| 272 |
colorAction = new Action("", IAction.AS_DROP_DOWN_MENU) { //$NON-NLS-1$ |
345 |
toolAction = new SelectDrawToolAction() { |
| 273 |
@Override |
346 |
@Override |
| 274 |
public void runWithEvent(final Event e) { |
347 |
public void run() { |
| 275 |
final ColorSelectionWindow colorWindow = new ColorSelectionWindow(getControl().getShell()) { |
348 |
fontAction.setEnabled(toolAction.getKind() == SelectDrawToolAction.TEXT); |
|
|
349 |
} |
| 350 |
}; |
| 351 |
toolAction.setEnabled(false); |
| 352 |
|
| 353 |
lineAction = new SelectLineToolAction(); |
| 354 |
lineAction.setEnabled(false); |
| 355 |
|
| 356 |
boldAction = new SelectBoldToolAction(); |
| 357 |
boldAction.setEnabled(false); |
| 276 |
|
358 |
|
| 277 |
@Override |
359 |
colorAction = new Action("", IAction.AS_PUSH_BUTTON) { //$NON-NLS-1$ |
| 278 |
protected Point getInitialLocation(Point initialSize) { |
360 |
@Override |
| 279 |
ToolItem toolItem = (ToolItem) e.widget; |
361 |
public void runWithEvent(final Event e) { |
| 280 |
Rectangle itemBounds = toolItem.getBounds(); |
362 |
// final ColorSelectionWindow colorWindow = new ColorSelectionWindow(getControl().getShell()) { |
| 281 |
Point location = toolItem.getParent().toDisplay(itemBounds.x + itemBounds.width, |
363 |
// |
| 282 |
itemBounds.y + itemBounds.height); |
364 |
// @Override |
| 283 |
location.x -= initialSize.x; |
365 |
// protected Point getInitialLocation(Point initialSize) { |
| 284 |
return location; |
366 |
// ToolItem toolItem = (ToolItem) e.widget; |
| 285 |
} |
367 |
// Rectangle itemBounds = toolItem.getBounds(); |
| 286 |
|
368 |
// Point location = toolItem.getParent().toDisplay(itemBounds.x + itemBounds.width, |
| 287 |
}; |
369 |
// itemBounds.y + itemBounds.height); |
| 288 |
colorWindow.setBlockOnOpen(true); |
370 |
// location.x -= initialSize.x; |
| 289 |
colorWindow.open(); |
371 |
// return location; |
| 290 |
RGB color = colorWindow.getSelectedRGB(); |
372 |
// } |
|
|
373 |
// |
| 374 |
// }; |
| 375 |
// colorWindow.setBlockOnOpen(true); |
| 376 |
// colorWindow.open(); |
| 377 |
// RGB color = colorWindow.getSelectedRGB(); |
| 378 |
final ColorDialog colorWindow = new ColorDialog(getControl().getShell()); |
| 379 |
colorWindow.setRGB(markColor.getRGB()); |
| 380 |
RGB color = colorWindow.open(); |
| 381 |
; |
| 291 |
if (color != null) { |
382 |
if (color != null) { |
| 292 |
setMarkColor(color); |
383 |
setMarkColor(color); |
| 293 |
} |
384 |
} |
|
Lines 298-324
Link Here
|
| 298 |
setMarkColor(new RGB(255, 85, 85)); |
389 |
setMarkColor(new RGB(255, 85, 85)); |
| 299 |
colorAction.setEnabled(false); |
390 |
colorAction.setEnabled(false); |
| 300 |
|
391 |
|
| 301 |
clearAction = new Action(Messages.ScreenshotCreationPage_Clear_Annotations, IAction.AS_PUSH_BUTTON) { |
392 |
fontAction = new Action("", IAction.AS_PUSH_BUTTON) { //$NON-NLS-1$ |
|
|
393 |
@Override |
| 394 |
public void runWithEvent(final Event e) { |
| 395 |
final FontDialog fontWindow = new FontDialog(getControl().getShell()); |
| 396 |
fontWindow.setFontList(markFont.getFontData()); |
| 397 |
fontWindow.setRGB(markFontColor.getRGB()); |
| 398 |
FontData fontData = fontWindow.open(); |
| 399 |
RGB fontColor = fontWindow.getRGB(); |
| 400 |
if (fontData != null) { |
| 401 |
setMarkFont(new FontData[] { fontData }, fontColor); |
| 402 |
fontAction.setToolTipText(getMarkFontInfo()); |
| 403 |
} |
| 404 |
} |
| 405 |
}; |
| 406 |
setMarkFont(getShell().getFont().getFontData(), new RGB(255, 0, 0)); |
| 407 |
fontAction.setToolTipText(getMarkFontInfo()); |
| 408 |
fontAction.setImageDescriptor(CommonImages.FONT_PROP); |
| 409 |
fontAction.setEnabled(false); |
| 410 |
|
| 411 |
clearAction = new Action(Messages.ScreenshotCreationPage_Clear, IAction.AS_PUSH_BUTTON) { |
| 302 |
@Override |
412 |
@Override |
| 303 |
public void run() { |
413 |
public void run() { |
| 304 |
clearAction.setEnabled(false); |
414 |
clearAction.setEnabled(false); |
| 305 |
workImageGC.drawImage(originalImage, 0, 0); |
415 |
workImageGC.drawImage(originalImage, 0, 0); |
| 306 |
canvas.redraw(); |
416 |
canvas.redraw(); |
| 307 |
setImageDirty(true); |
417 |
setImageDirty(true); |
|
|
418 |
|
| 419 |
historyMouseEvent = new ArrayList<int[]>(); |
| 420 |
historyDrawTool = new ArrayList<int[]>(); |
| 421 |
historyDrawText = new ArrayList<StringBuffer>(); |
| 422 |
historyDrawFont = new ArrayList<String>(); |
| 423 |
historyCheckpoint = 0; |
| 424 |
undoAction.setEnabled(false); |
| 425 |
redoAction.setEnabled(false); |
| 308 |
} |
426 |
} |
| 309 |
}; |
427 |
}; |
| 310 |
clearAction.setToolTipText(Messages.ScreenshotCreationPage_Clear_all_annotations_made_on_screenshot_image); |
428 |
clearAction.setToolTipText(Messages.ScreenshotCreationPage_Clear_all_annotations_made_on_screenshot_image); |
| 311 |
clearAction.setImageDescriptor(CommonImages.CLEAR); |
429 |
clearAction.setImageDescriptor(CommonImages.CLEAR); |
| 312 |
clearAction.setEnabled(false); |
430 |
clearAction.setEnabled(false); |
| 313 |
|
431 |
|
|
|
432 |
undoAction = new Action(Messages.ScreenshotCreationPage_Undo) { |
| 433 |
@Override |
| 434 |
public void run() { |
| 435 |
if (historyCheckpoint > 0) { |
| 436 |
historyCheckpoint--; |
| 437 |
drawAnnotationHistory(); |
| 438 |
} |
| 439 |
if (historyCheckpoint == 0) { |
| 440 |
undoAction.setEnabled(false); |
| 441 |
} |
| 442 |
if (historyCheckpoint < historyDrawTool.size()) { |
| 443 |
redoAction.setEnabled(true); |
| 444 |
} |
| 445 |
} |
| 446 |
}; |
| 447 |
undoAction.setToolTipText(Messages.ScreenshotCreationPage_Undo_annotation); |
| 448 |
undoAction.setImageDescriptor(CommonImages.EDIT_UNDO); |
| 449 |
undoAction.setEnabled(false); |
| 450 |
|
| 451 |
redoAction = new Action(Messages.ScreenshotCreationPage_Redo) { |
| 452 |
@Override |
| 453 |
public void run() { |
| 454 |
if (historyCheckpoint < historyDrawTool.size()) { |
| 455 |
historyCheckpoint++; |
| 456 |
drawAnnotationHistory(); |
| 457 |
} |
| 458 |
if (historyCheckpoint > 0) { |
| 459 |
undoAction.setEnabled(true); |
| 460 |
} |
| 461 |
if (historyCheckpoint >= historyDrawTool.size()) { |
| 462 |
redoAction.setEnabled(false); |
| 463 |
} |
| 464 |
} |
| 465 |
}; |
| 466 |
redoAction.setToolTipText(Messages.ScreenshotCreationPage_Redo_annotation); |
| 467 |
redoAction.setImageDescriptor(CommonImages.EDIT_REDO); |
| 468 |
redoAction.setEnabled(false); |
| 469 |
|
| 314 |
tbm.add(createAndConfigureCI(captureAction)); |
470 |
tbm.add(createAndConfigureCI(captureAction)); |
| 315 |
tbm.add(createAndConfigureCI(fitAction)); |
|
|
| 316 |
tbm.add(new Separator()); |
471 |
tbm.add(new Separator()); |
|
|
472 |
tbm.add(createAndConfigureCI(fitAction)); |
| 317 |
tbm.add(createAndConfigureCI(cropAction)); |
473 |
tbm.add(createAndConfigureCI(cropAction)); |
| 318 |
tbm.add(createAndConfigureCI(markAction)); |
474 |
tbm.add(createAndConfigureCI(markAction)); |
|
|
475 |
tbm.add(new Separator()); |
| 476 |
tbm.add(createAndConfigureCI(toolAction)); |
| 477 |
tbm.add(createAndConfigureCI(lineAction)); |
| 478 |
tbm.add(createAndConfigureCI(boldAction)); |
| 319 |
tbm.add(createAndConfigureCI(colorAction)); |
479 |
tbm.add(createAndConfigureCI(colorAction)); |
|
|
480 |
tbm.add(createAndConfigureCI(fontAction)); |
| 320 |
tbm.add(new Separator()); |
481 |
tbm.add(new Separator()); |
| 321 |
tbm.add(createAndConfigureCI(clearAction)); |
482 |
tbm.add(createAndConfigureCI(clearAction)); |
|
|
483 |
tbm.add(createAndConfigureCI(undoAction)); |
| 484 |
tbm.add(createAndConfigureCI(redoAction)); |
| 322 |
|
485 |
|
| 323 |
scrolledComposite = new ScrolledComposite(vf, SWT.V_SCROLL | SWT.H_SCROLL); |
486 |
scrolledComposite = new ScrolledComposite(vf, SWT.V_SCROLL | SWT.H_SCROLL); |
| 324 |
canvas = new Canvas(scrolledComposite, SWT.DOUBLE_BUFFERED); |
487 |
canvas = new Canvas(scrolledComposite, SWT.DOUBLE_BUFFERED); |
|
Lines 330-340
Link Here
|
| 330 |
Rectangle imageBounds = workImage.getBounds(); |
493 |
Rectangle imageBounds = workImage.getBounds(); |
| 331 |
Rectangle canvasBounds = canvas.getClientArea(); |
494 |
Rectangle canvasBounds = canvas.getClientArea(); |
| 332 |
|
495 |
|
| 333 |
if (fitAction.isChecked()) { |
496 |
switch (fitAction.getKind()) { |
| 334 |
e.gc.drawImage(workImage, 0, 0, imageBounds.width, imageBounds.height, 0, 0, |
497 |
case SelectZoomToolAction.FIT: |
| 335 |
canvasBounds.width, canvasBounds.height); |
498 |
e.gc.drawImage(workImage, 0, 0, imageBounds.width, imageBounds.height, // |
| 336 |
} else { |
499 |
0, 0, canvasBounds.width, canvasBounds.height); |
|
|
500 |
break; |
| 501 |
case SelectZoomToolAction.ZOOM8X: |
| 502 |
e.gc.drawImage(workImage, 0, 0, imageBounds.width, imageBounds.height, // |
| 503 |
0, 0, imageBounds.width * 8, imageBounds.height * 8); |
| 504 |
break; |
| 505 |
case SelectZoomToolAction.ZOOM4X: |
| 506 |
e.gc.drawImage(workImage, 0, 0, imageBounds.width, imageBounds.height, // |
| 507 |
0, 0, imageBounds.width * 4, imageBounds.height * 4); |
| 508 |
break; |
| 509 |
case SelectZoomToolAction.ZOOM2X: |
| 510 |
e.gc.drawImage(workImage, 0, 0, imageBounds.width, imageBounds.height, // |
| 511 |
0, 0, imageBounds.width * 2, imageBounds.height * 2); |
| 512 |
break; |
| 513 |
default: |
| 337 |
e.gc.drawImage(workImage, 0, 0); |
514 |
e.gc.drawImage(workImage, 0, 0); |
|
|
515 |
break; |
| 338 |
} |
516 |
} |
| 339 |
drawSelection(e.gc); |
517 |
drawSelection(e.gc); |
| 340 |
} else { |
518 |
} else { |
|
Lines 347-353
Link Here
|
| 347 |
scrolledComposite.addControlListener(new ControlAdapter() { |
525 |
scrolledComposite.addControlListener(new ControlAdapter() { |
| 348 |
@Override |
526 |
@Override |
| 349 |
public void controlResized(ControlEvent e) { |
527 |
public void controlResized(ControlEvent e) { |
| 350 |
if (fitAction.isChecked()) { |
528 |
if (fitAction.getKind() == SelectZoomToolAction.FIT) { |
| 351 |
refreshCanvasSize(); |
529 |
refreshCanvasSize(); |
| 352 |
} |
530 |
} |
| 353 |
} |
531 |
} |
|
Lines 367-372
Link Here
|
| 367 |
return ci; |
545 |
return ci; |
| 368 |
} |
546 |
} |
| 369 |
|
547 |
|
|
|
548 |
private void setMarkFont(FontData[] fontData, RGB fontColor) { |
| 549 |
if (markFont != null) { |
| 550 |
markFont.dispose(); |
| 551 |
} |
| 552 |
markFont = new Font(getShell().getDisplay(), fontData[0]); |
| 553 |
markFontColor = new Color(getShell().getDisplay(), fontColor); |
| 554 |
} |
| 555 |
|
| 556 |
private String getMarkFontInfo() { |
| 557 |
if (markFont == null) { |
| 558 |
return Messages.ScreenshotCreationPage_Change_text_font; |
| 559 |
} |
| 560 |
FontData[] fd = markFont.getFontData(); |
| 561 |
String info = NLS.bind(Messages.ScreenshotCreationPage_Font_Name_Size, // |
| 562 |
new Object[] { fd[0].getName(), fd[0].getHeight() + "" }); //$NON-NLS-1$ |
| 563 |
int style = fd[0].getStyle(); |
| 564 |
if ((style & SWT.BOLD) != 0) { |
| 565 |
info = info + Messages.ScreenshotCreationPage_Font_Bold; |
| 566 |
} |
| 567 |
if ((style & SWT.ITALIC) != 0) { |
| 568 |
info = info + Messages.ScreenshotCreationPage_Font_Italic; |
| 569 |
} |
| 570 |
return info; |
| 571 |
} |
| 572 |
|
| 370 |
private void setMarkColor(RGB color) { |
573 |
private void setMarkColor(RGB color) { |
| 371 |
if (markColor != null) { |
574 |
if (markColor != null) { |
| 372 |
markColor.dispose(); |
575 |
markColor.dispose(); |
|
Lines 455-460
Link Here
|
| 455 |
return isPageComplete(); |
658 |
return isPageComplete(); |
| 456 |
} |
659 |
} |
| 457 |
|
660 |
|
|
|
661 |
private void captureScreenshotContent(Image image) { |
| 662 |
final Display display = getShell().getDisplay(); |
| 663 |
disposeImageResources(); |
| 664 |
originalImage = image; |
| 665 |
Rectangle displayBounds = originalImage.getBounds(); |
| 666 |
workImage = new Image(display, displayBounds.width, displayBounds.height); |
| 667 |
GC gc = new GC(workImage); |
| 668 |
gc.drawImage(originalImage, 0, 0); |
| 669 |
gc.dispose(); |
| 670 |
|
| 671 |
workImageGC = new GC(workImage); |
| 672 |
workImageGC.setBackground(new Color(getShell().getDisplay(), 255, 255, 255)); |
| 673 |
workImageGC.setForeground(markColor); |
| 674 |
workImageGC.setLineWidth(4); |
| 675 |
workImageGC.setLineCap(SWT.CAP_ROUND); |
| 676 |
|
| 677 |
scrolledComposite.setEnabled(true); |
| 678 |
clearSelection(); |
| 679 |
refreshCanvasSize(); |
| 680 |
|
| 681 |
setPageComplete(true); |
| 682 |
} |
| 683 |
|
| 458 |
private void captureScreenshotContent() { |
684 |
private void captureScreenshotContent() { |
| 459 |
final Display display = getShell().getDisplay(); |
685 |
final Display display = getShell().getDisplay(); |
| 460 |
final Shell wizardShell = getWizard().getContainer().getShell(); |
686 |
final Shell wizardShell = getWizard().getContainer().getShell(); |
|
Lines 659-664
Link Here
|
| 659 |
canvas.setCursor(crossCursor); |
885 |
canvas.setCursor(crossCursor); |
| 660 |
} |
886 |
} |
| 661 |
} else if (currentAction == EditorAction.MARKING) { |
887 |
} else if (currentAction == EditorAction.MARKING) { |
|
|
888 |
if (startPoint != null) { |
| 889 |
if (toolAction.getKind() == SelectDrawToolAction.FREE) { |
| 890 |
int[] history = new int[3]; |
| 891 |
history[0] = SWT.MouseMove; |
| 892 |
history[1] = scaledX; |
| 893 |
history[2] = scaledY; |
| 894 |
historyMouseEvent.add(history); |
| 895 |
} else { |
| 896 |
int[] history = historyMouseEvent.get(historyMouseEvent.size() - 1); |
| 897 |
if (history[0] == SWT.MouseMove) { |
| 898 |
history[1] = scaledX; |
| 899 |
history[2] = scaledY; |
| 900 |
} else { |
| 901 |
history = new int[3]; |
| 902 |
history[0] = SWT.MouseMove; |
| 903 |
history[1] = scaledX; |
| 904 |
history[2] = scaledY; |
| 905 |
historyMouseEvent.add(history); |
| 906 |
} |
| 907 |
} |
| 908 |
} |
| 909 |
|
| 662 |
drawMarkLine(scaledX, scaledY); |
910 |
drawMarkLine(scaledX, scaledY); |
| 663 |
|
911 |
|
| 664 |
Cursor markCursor = cursors.get(CURSOR_MARK_TOOL); |
912 |
Cursor markCursor = cursors.get(CURSOR_MARK_TOOL); |
|
Lines 699-707
Link Here
|
| 699 |
canvas.redraw(); |
947 |
canvas.redraw(); |
| 700 |
setImageDirty(true); |
948 |
setImageDirty(true); |
| 701 |
} else if (currentAction == EditorAction.MARKING) { |
949 |
} else if (currentAction == EditorAction.MARKING) { |
|
|
950 |
if (startPoint != null) { |
| 951 |
if (toolAction.getKind() != SelectDrawToolAction.FREE) { |
| 952 |
if (toolAction.getKind() == SelectDrawToolAction.TEXT) { |
| 953 |
drawAnnotationText(); |
| 954 |
} |
| 955 |
previousImage.dispose(); |
| 956 |
previousImage = null; |
| 957 |
} |
| 958 |
|
| 959 |
int[] history = new int[3]; |
| 960 |
history[0] = SWT.MouseUp; |
| 961 |
history[1] = 0; |
| 962 |
history[2] = 0; |
| 963 |
historyMouseEvent.add(history); |
| 964 |
} |
| 965 |
|
| 702 |
startPoint = null; |
966 |
startPoint = null; |
| 703 |
setImageDirty(true); |
967 |
setImageDirty(true); |
|
|
968 |
|
| 969 |
} |
| 970 |
} |
| 971 |
|
| 972 |
/** |
| 973 |
* Input annotation text and draw text |
| 974 |
*/ |
| 975 |
private void drawAnnotationText() { |
| 976 |
workImageGC.drawImage(previousImage, 0, 0); |
| 977 |
|
| 978 |
int[] history = historyMouseEvent.get(historyMouseEvent.size() - 1); |
| 979 |
if (history[0] != SWT.MouseMove) { |
| 980 |
historyCheckpoint--; |
| 981 |
updateAnnotationHistory(); |
| 982 |
return; |
| 983 |
} |
| 984 |
|
| 985 |
final Rectangle bounds = new Rectangle(startPoint.x, startPoint.y, history[1] - startPoint.x, |
| 986 |
history[2] - startPoint.y); |
| 987 |
|
| 988 |
textArea = new Text(canvas, SWT.MULTI | SWT.WRAP); |
| 989 |
textArea.addListener(SWT.Deactivate, new Listener() { |
| 990 |
|
| 991 |
public void handleEvent(Event event) { |
| 992 |
String text = textArea.getText(); |
| 993 |
{ |
| 994 |
String newtext = ""; //$NON-NLS-1$ |
| 995 |
Rectangle rect = textArea.getBounds(); |
| 996 |
textArea.setSize(rect.width, textArea.getLineHeight()); |
| 997 |
int currpos = 0; |
| 998 |
int charpos = currpos; |
| 999 |
textArea.setSelection(currpos); |
| 1000 |
textArea.setTopIndex(0); |
| 1001 |
int linepos = textArea.getTopIndex(); |
| 1002 |
boolean remove1st = false; |
| 1003 |
String line; |
| 1004 |
while (currpos < text.length()) { |
| 1005 |
int y = textArea.getTopIndex(); |
| 1006 |
if (linepos != y) { |
| 1007 |
line = text.substring(charpos, currpos); |
| 1008 |
if (line.endsWith("\n")) { //$NON-NLS-1$ |
| 1009 |
line = line.substring(0, line.length() - 1); |
| 1010 |
} |
| 1011 |
newtext = newtext + "\n" + line; //$NON-NLS-1$ |
| 1012 |
remove1st = true; |
| 1013 |
charpos = currpos; |
| 1014 |
linepos = y; |
| 1015 |
} |
| 1016 |
currpos++; |
| 1017 |
textArea.setSelection(currpos); |
| 1018 |
} |
| 1019 |
line = text.substring(charpos, currpos); |
| 1020 |
if (line.endsWith("\n")) { //$NON-NLS-1$ |
| 1021 |
line = line.substring(0, line.length() - 1); |
| 1022 |
} |
| 1023 |
if (line.length() > 0) { |
| 1024 |
newtext = newtext + "\n" + text.substring(charpos, currpos); //$NON-NLS-1$ |
| 1025 |
remove1st = true; |
| 1026 |
} |
| 1027 |
currpos = newtext.indexOf("\r"); //$NON-NLS-1$ |
| 1028 |
while (currpos > 0) { |
| 1029 |
newtext = newtext.substring(0, currpos) + newtext.substring(currpos + 1); |
| 1030 |
currpos = newtext.indexOf("\r"); //$NON-NLS-1$ |
| 1031 |
} |
| 1032 |
newtext = newtext.replace("\t", " "); //$NON-NLS-1$ //$NON-NLS-2$ |
| 1033 |
if (remove1st) { |
| 1034 |
newtext = newtext.substring(1); |
| 1035 |
} |
| 1036 |
text = newtext; |
| 1037 |
} |
| 1038 |
|
| 1039 |
textArea.dispose(); |
| 1040 |
textArea = null; |
| 1041 |
|
| 1042 |
if (text.length() > 0) { |
| 1043 |
historyDrawText.get(historyCheckpoint - 1).append(text); |
| 1044 |
workImageGC.setFont(markFont); |
| 1045 |
workImageGC.setForeground(markFontColor); |
| 1046 |
workImageGC.setClipping(bounds); |
| 1047 |
workImageGC.drawText(text, bounds.x, bounds.y, true); |
| 1048 |
workImageGC.setClipping((Rectangle) null); |
| 1049 |
workImageGC.setForeground(markColor); |
| 1050 |
} else { |
| 1051 |
historyCheckpoint--; |
| 1052 |
updateAnnotationHistory(); |
| 1053 |
} |
| 1054 |
canvas.redraw(); |
| 1055 |
} |
| 1056 |
}); |
| 1057 |
|
| 1058 |
int gp = (int) Math.round(3 * scaleFactor); |
| 1059 |
int xs = (int) Math.round(startPoint.x * scaleFactor); |
| 1060 |
int ys = (int) Math.round(startPoint.y * scaleFactor); |
| 1061 |
int xe = (int) Math.round(history[1] * scaleFactor); |
| 1062 |
int ye = (int) Math.round(history[2] * scaleFactor); |
| 1063 |
textArea.setBounds(new Rectangle(xs - gp, ys, xe - xs + gp + gp, ye - ys)); |
| 1064 |
textArea.setForeground(markFontColor); |
| 1065 |
textArea.setTabs(1); |
| 1066 |
if (scaleFactor != 1.0) { |
| 1067 |
FontData[] fd = markFont.getFontData(); |
| 1068 |
fd[0].setHeight((int) Math.round(fd[0].getHeight() * scaleFactor)); |
| 1069 |
textArea.setFont(new Font(getShell().getDisplay(), fd[0])); |
| 1070 |
} else { |
| 1071 |
textArea.setFont(markFont); |
| 704 |
} |
1072 |
} |
|
|
1073 |
textArea.setFocus(); |
| 705 |
} |
1074 |
} |
| 706 |
|
1075 |
|
| 707 |
/** |
1076 |
/** |
|
Lines 713-718
Link Here
|
| 713 |
int scaledY = (int) (e.y / scaleFactor); |
1082 |
int scaledY = (int) (e.y / scaleFactor); |
| 714 |
|
1083 |
|
| 715 |
if (currentAction == EditorAction.MARKING) { |
1084 |
if (currentAction == EditorAction.MARKING) { |
|
|
1085 |
updateAnnotationHistory(); |
| 1086 |
|
| 1087 |
int toolKind = toolAction.getKind(); |
| 1088 |
int[] history = new int[5]; |
| 1089 |
history[0] = historyMouseEvent.size(); |
| 1090 |
history[1] = toolAction.getKind(); |
| 1091 |
history[2] = lineAction.getKind(); |
| 1092 |
history[3] = boldAction.getKind(); |
| 1093 |
if (toolKind == SelectDrawToolAction.TEXT) { |
| 1094 |
history[4] = (markFontColor.getRed() << 16) // |
| 1095 |
+ (markFontColor.getGreen() << 8) // |
| 1096 |
+ markFontColor.getBlue(); |
| 1097 |
} else { |
| 1098 |
history[4] = (markColor.getRed() << 16) // |
| 1099 |
+ (markColor.getGreen() << 8) // |
| 1100 |
+ markColor.getBlue(); |
| 1101 |
} |
| 1102 |
historyDrawTool.add(history); |
| 1103 |
historyDrawText.add(new StringBuffer()); |
| 1104 |
if (toolKind == SelectDrawToolAction.TEXT) { |
| 1105 |
FontData[] fd = markFont.getFontData(); |
| 1106 |
historyDrawFont.add(fd[0].toString()); |
| 1107 |
} else { |
| 1108 |
historyDrawFont.add(""); //$NON-NLS-1$ |
| 1109 |
} |
| 1110 |
historyCheckpoint = historyDrawTool.size(); |
| 1111 |
|
| 1112 |
history = new int[3]; |
| 1113 |
history[0] = SWT.MouseDown; |
| 1114 |
history[1] = scaledX; |
| 1115 |
history[2] = scaledY; |
| 1116 |
historyMouseEvent.add(history); |
| 1117 |
undoAction.setEnabled(true); |
| 1118 |
|
| 1119 |
if (toolKind != SelectDrawToolAction.FREE) { |
| 1120 |
Display display = getShell().getDisplay(); |
| 1121 |
previousImage = new Image(display, workImage.getBounds()); |
| 1122 |
GC gc = new GC(previousImage); |
| 1123 |
gc.drawImage(workImage, 0, 0); |
| 1124 |
gc.dispose(); |
| 1125 |
} |
| 1126 |
|
| 1127 |
if (toolKind != SelectDrawToolAction.TEXT) { |
| 1128 |
workImageGC.setLineStyle(lineAction.getKind()); |
| 1129 |
workImageGC.setLineWidth(boldAction.getKind()); |
| 1130 |
workImageGC.setForeground(markFontColor); |
| 1131 |
} else { |
| 1132 |
workImageGC.setLineStyle(SWT.LINE_DOT); |
| 1133 |
workImageGC.setLineWidth(1); |
| 1134 |
workImageGC.setForeground(new Color(getShell().getDisplay(), 0, 0, 0)); |
| 1135 |
} |
| 1136 |
|
| 716 |
startPoint = new Point(scaledX, scaledY); |
1137 |
startPoint = new Point(scaledX, scaledY); |
| 717 |
drawMarkLine(scaledX, scaledY); |
1138 |
drawMarkLine(scaledX, scaledY); |
| 718 |
canvas.setCursor(cursors.get(CURSOR_MARK_TOOL)); |
1139 |
canvas.setCursor(cursors.get(CURSOR_MARK_TOOL)); |
|
Lines 779-785
Link Here
|
| 779 |
* Calling this method under other circumstances may lead to strange behavior in the scrolled composite |
1200 |
* Calling this method under other circumstances may lead to strange behavior in the scrolled composite |
| 780 |
*/ |
1201 |
*/ |
| 781 |
private void refreshCanvasSize() { |
1202 |
private void refreshCanvasSize() { |
| 782 |
if (fitAction.isChecked()) { |
1203 |
if (fitAction.getKind() == SelectZoomToolAction.FIT) { |
| 783 |
// This little hack is necessary to get the client area without scrollbars; |
1204 |
// This little hack is necessary to get the client area without scrollbars; |
| 784 |
// they'll be automatically restored if necessary after Canvas.setBounds() |
1205 |
// they'll be automatically restored if necessary after Canvas.setBounds() |
| 785 |
scrolledComposite.getHorizontalBar().setVisible(false); |
1206 |
scrolledComposite.getHorizontalBar().setVisible(false); |
|
Lines 798-809
Link Here
|
| 798 |
} |
1219 |
} |
| 799 |
canvas.setBounds(bounds); |
1220 |
canvas.setBounds(bounds); |
| 800 |
} else { |
1221 |
} else { |
| 801 |
scaleFactor = 1.0; |
1222 |
if (fitAction.getKind() == SelectZoomToolAction.ZOOM8X) { |
|
|
1223 |
scaleFactor = 8.0; |
| 1224 |
} else if (fitAction.getKind() == SelectZoomToolAction.ZOOM4X) { |
| 1225 |
scaleFactor = 4.0; |
| 1226 |
} else if (fitAction.getKind() == SelectZoomToolAction.ZOOM2X) { |
| 1227 |
scaleFactor = 2.0; |
| 1228 |
} else { |
| 1229 |
scaleFactor = 1.0; |
| 1230 |
} |
| 802 |
Rectangle bounds = scrolledComposite.getClientArea(); |
1231 |
Rectangle bounds = scrolledComposite.getClientArea(); |
| 803 |
if (workImage != null) { |
1232 |
if (workImage != null) { |
| 804 |
Rectangle imageBounds = workImage.getBounds(); |
1233 |
Rectangle imageBounds = workImage.getBounds(); |
| 805 |
bounds.width = imageBounds.width; |
1234 |
bounds.width = (int) Math.round(imageBounds.width * scaleFactor); |
| 806 |
bounds.height = imageBounds.height; |
1235 |
bounds.height = (int) Math.round(imageBounds.height * scaleFactor); |
| 807 |
} |
1236 |
} |
| 808 |
canvas.setBounds(bounds); |
1237 |
canvas.setBounds(bounds); |
| 809 |
} |
1238 |
} |
|
Lines 811-816
Link Here
|
| 811 |
canvas.redraw(); |
1240 |
canvas.redraw(); |
| 812 |
} |
1241 |
} |
| 813 |
|
1242 |
|
|
|
1243 |
private void updateAnnotationHistory() { |
| 1244 |
int[] history; |
| 1245 |
if (historyCheckpoint < historyDrawTool.size()) { |
| 1246 |
history = historyDrawTool.get(historyCheckpoint); |
| 1247 |
while (history[0] < historyMouseEvent.size()) { |
| 1248 |
historyMouseEvent.remove(historyMouseEvent.size() - 1); |
| 1249 |
} |
| 1250 |
while (historyCheckpoint < historyDrawTool.size()) { |
| 1251 |
historyDrawTool.remove(historyDrawTool.size() - 1); |
| 1252 |
} |
| 1253 |
while (historyCheckpoint < historyDrawText.size()) { |
| 1254 |
historyDrawText.remove(historyDrawText.size() - 1); |
| 1255 |
} |
| 1256 |
while (historyCheckpoint < historyDrawFont.size()) { |
| 1257 |
historyDrawFont.remove(historyDrawFont.size() - 1); |
| 1258 |
} |
| 1259 |
redoAction.setEnabled(false); |
| 1260 |
} |
| 1261 |
|
| 1262 |
undoAction.setEnabled(historyCheckpoint > 0); |
| 1263 |
} |
| 1264 |
|
| 1265 |
/** |
| 1266 |
* Draw Annotation with history |
| 1267 |
*/ |
| 1268 |
private void drawAnnotationHistory() { |
| 1269 |
workImageGC.drawImage(originalImage, 0, 0); |
| 1270 |
int[] history; |
| 1271 |
for (int c = 0; c < historyCheckpoint; c++) { |
| 1272 |
history = historyDrawTool.get(c); |
| 1273 |
int toolKind = history[1]; |
| 1274 |
int boldlKind = history[3]; |
| 1275 |
workImageGC.setLineStyle(history[2]); |
| 1276 |
workImageGC.setLineWidth(boldlKind); |
| 1277 |
workImageGC.setForeground(new Color(getShell().getDisplay(), // |
| 1278 |
history[4] >> 16, // |
| 1279 |
(history[4] >> 8) & 0x00ff, // |
| 1280 |
history[4] & 0x00ff)); |
| 1281 |
|
| 1282 |
int h = history[0]; |
| 1283 |
history = historyMouseEvent.get(h); |
| 1284 |
int start_x = history[1]; |
| 1285 |
int start_y = history[2]; |
| 1286 |
for (h++; h < historyMouseEvent.size(); h++) { |
| 1287 |
history = historyMouseEvent.get(h); |
| 1288 |
if (history[0] == SWT.MouseUp) { |
| 1289 |
break; |
| 1290 |
} |
| 1291 |
int x = history[1]; |
| 1292 |
int y = history[2]; |
| 1293 |
if (toolKind == SelectDrawToolAction.FREE) { |
| 1294 |
workImageGC.drawLine(start_x, start_y, x, y); |
| 1295 |
start_x = x; |
| 1296 |
start_y = y; |
| 1297 |
} else { |
| 1298 |
if (start_x == x && start_y == y) { |
| 1299 |
workImageGC.drawLine(start_x, start_y, x, y); |
| 1300 |
} else { |
| 1301 |
Color backColor; |
| 1302 |
int rounded; |
| 1303 |
int width = x - start_x; |
| 1304 |
int height = y - start_y; |
| 1305 |
switch (toolKind) { |
| 1306 |
case SelectDrawToolAction.LINE: |
| 1307 |
workImageGC.drawLine(start_x, start_y, x, y); |
| 1308 |
break; |
| 1309 |
case SelectDrawToolAction.BOX: |
| 1310 |
workImageGC.drawRectangle(start_x, start_y, width, height); |
| 1311 |
break; |
| 1312 |
case SelectDrawToolAction.RBOX: |
| 1313 |
rounded = boldlKind * 8; |
| 1314 |
workImageGC.drawRoundRectangle(start_x, start_y, width, height, rounded, rounded); |
| 1315 |
break; |
| 1316 |
case SelectDrawToolAction.OVAL: |
| 1317 |
workImageGC.drawOval(start_x, start_y, width, height); |
| 1318 |
break; |
| 1319 |
case SelectDrawToolAction.FILL_BOX: |
| 1320 |
backColor = workImageGC.getBackground(); |
| 1321 |
workImageGC.setBackground(markColor); |
| 1322 |
workImageGC.fillRectangle(start_x, start_y, width, height); |
| 1323 |
workImageGC.setBackground(backColor); |
| 1324 |
break; |
| 1325 |
case SelectDrawToolAction.FILL_RBOX: |
| 1326 |
rounded = boldlKind * 8; |
| 1327 |
backColor = workImageGC.getBackground(); |
| 1328 |
workImageGC.setBackground(markColor); |
| 1329 |
workImageGC.fillRoundRectangle(start_x, start_y, width, height, rounded, rounded); |
| 1330 |
workImageGC.setBackground(backColor); |
| 1331 |
break; |
| 1332 |
case SelectDrawToolAction.FILL_OVAL: |
| 1333 |
backColor = workImageGC.getBackground(); |
| 1334 |
workImageGC.setBackground(markColor); |
| 1335 |
workImageGC.fillOval(start_x, start_y, width, height); |
| 1336 |
workImageGC.setBackground(backColor); |
| 1337 |
break; |
| 1338 |
case SelectDrawToolAction.TEXT: |
| 1339 |
StringBuffer text = historyDrawText.get(c); |
| 1340 |
FontData fontData = new FontData(historyDrawFont.get(c)); |
| 1341 |
workImageGC.setFont(new Font(getShell().getDisplay(), fontData)); |
| 1342 |
workImageGC.setClipping(start_x, start_y, width, height); |
| 1343 |
workImageGC.drawText(text.toString(), start_x, start_y, true); |
| 1344 |
workImageGC.setClipping((Rectangle) null); |
| 1345 |
break; |
| 1346 |
} |
| 1347 |
} |
| 1348 |
} |
| 1349 |
} |
| 1350 |
} |
| 1351 |
|
| 1352 |
workImageGC.setForeground(markColor); |
| 1353 |
workImageGC.setLineStyle(lineAction.getKind()); |
| 1354 |
workImageGC.setLineWidth(boldAction.getKind()); |
| 1355 |
workImageGC.setFont(markFont); |
| 1356 |
canvas.redraw(); |
| 1357 |
} |
| 1358 |
|
| 814 |
/** |
1359 |
/** |
| 815 |
* Decorates the screenshot canvas with the selection rectangle, resize grab points and other adornments |
1360 |
* Decorates the screenshot canvas with the selection rectangle, resize grab points and other adornments |
| 816 |
*/ |
1361 |
*/ |
|
Lines 850-863
Link Here
|
| 850 |
} |
1395 |
} |
| 851 |
|
1396 |
|
| 852 |
/** |
1397 |
/** |
| 853 |
* Connects the previous mark point to the new reference point, by drawing a new line |
1398 |
* Connects the previous mark point to the new reference point, by drawing a new line, rectangle or oval |
| 854 |
*/ |
1399 |
*/ |
| 855 |
private void drawMarkLine(int x, int y) { |
1400 |
private void drawMarkLine(int x, int y) { |
| 856 |
if (startPoint != null) { |
1401 |
if (startPoint != null) { |
| 857 |
clearAction.setEnabled(true); |
1402 |
clearAction.setEnabled(true); |
| 858 |
workImageGC.drawLine(startPoint.x, startPoint.y, x, y); |
1403 |
if (toolAction.getKind() == SelectDrawToolAction.FREE) { |
| 859 |
startPoint.x = x; |
1404 |
workImageGC.drawLine(startPoint.x, startPoint.y, x, y); |
| 860 |
startPoint.y = y; |
1405 |
startPoint.x = x; |
|
|
1406 |
startPoint.y = y; |
| 1407 |
} else { |
| 1408 |
workImageGC.drawImage(previousImage, 0, 0); |
| 1409 |
if (startPoint.x == x && startPoint.y == y) { |
| 1410 |
workImageGC.drawLine(startPoint.x, startPoint.y, x, y); |
| 1411 |
} else { |
| 1412 |
Color backColor; |
| 1413 |
int rounded; |
| 1414 |
int width = x - startPoint.x; |
| 1415 |
int height = y - startPoint.y; |
| 1416 |
switch (toolAction.getKind()) { |
| 1417 |
case SelectDrawToolAction.LINE: |
| 1418 |
workImageGC.drawLine(startPoint.x, startPoint.y, x, y); |
| 1419 |
break; |
| 1420 |
case SelectDrawToolAction.BOX: |
| 1421 |
workImageGC.drawRectangle(startPoint.x, startPoint.y, width, height); |
| 1422 |
break; |
| 1423 |
case SelectDrawToolAction.RBOX: |
| 1424 |
rounded = boldAction.getKind() * 8; |
| 1425 |
workImageGC.drawRoundRectangle(startPoint.x, startPoint.y, width, height, rounded, rounded); |
| 1426 |
break; |
| 1427 |
case SelectDrawToolAction.OVAL: |
| 1428 |
workImageGC.drawOval(startPoint.x, startPoint.y, width, height); |
| 1429 |
break; |
| 1430 |
case SelectDrawToolAction.FILL_BOX: |
| 1431 |
backColor = workImageGC.getBackground(); |
| 1432 |
workImageGC.setBackground(markColor); |
| 1433 |
workImageGC.fillRectangle(startPoint.x, startPoint.y, width, height); |
| 1434 |
workImageGC.setBackground(backColor); |
| 1435 |
break; |
| 1436 |
case SelectDrawToolAction.FILL_RBOX: |
| 1437 |
rounded = boldAction.getKind() * 8; |
| 1438 |
backColor = workImageGC.getBackground(); |
| 1439 |
workImageGC.setBackground(markColor); |
| 1440 |
workImageGC.fillRoundRectangle(startPoint.x, startPoint.y, width, height, rounded, rounded); |
| 1441 |
workImageGC.setBackground(backColor); |
| 1442 |
break; |
| 1443 |
case SelectDrawToolAction.FILL_OVAL: |
| 1444 |
backColor = workImageGC.getBackground(); |
| 1445 |
workImageGC.setBackground(markColor); |
| 1446 |
workImageGC.fillOval(startPoint.x, startPoint.y, width, height); |
| 1447 |
workImageGC.setBackground(backColor); |
| 1448 |
break; |
| 1449 |
case SelectDrawToolAction.TEXT: |
| 1450 |
workImageGC.fillRectangle(startPoint.x, startPoint.y, width, height); |
| 1451 |
workImageGC.drawRectangle(startPoint.x, startPoint.y, width, height); |
| 1452 |
break; |
| 1453 |
} |
| 1454 |
} |
| 1455 |
} |
| 861 |
canvas.redraw(); |
1456 |
canvas.redraw(); |
| 862 |
} |
1457 |
} |
| 863 |
} |
1458 |
} |