1 | package org.expeditee.gio;
|
---|
2 |
|
---|
3 | import org.expeditee.core.Image;
|
---|
4 |
|
---|
5 | /**
|
---|
6 | * In charge of getting/setting the OS clipboard. Any Object can be
|
---|
7 | * set on the clipboard, but typically only other instances of Expeditee
|
---|
8 | * will be able to read this. Similarly generic data will only be available
|
---|
9 | * to get if it has been set by another Expeditee instance. Additionally,
|
---|
10 | * the clipboard data can have an image- or string-representation, which
|
---|
11 | * external applications that can copy/paste image/string data will be able
|
---|
12 | * to set/get.
|
---|
13 | *
|
---|
14 | * @author cts16
|
---|
15 | */
|
---|
16 | public abstract class ClipboardManager {
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * Sets the clipboard to the given data. If data is null, should leave
|
---|
20 | * the clipboard unchanged (however, if data is not null but all of its
|
---|
21 | * fields are null, this will clear the clipboard).
|
---|
22 | */
|
---|
23 | public abstract void set(ClipboardData data);
|
---|
24 |
|
---|
25 | /** Gets the data that is currently on the clipboard. */
|
---|
26 | public abstract ClipboardData get();
|
---|
27 |
|
---|
28 | /** Representation of the data on the clipboard. */
|
---|
29 | public static class ClipboardData {
|
---|
30 |
|
---|
31 | /** Any generic data on the clipboard (for Expeditee use only). */
|
---|
32 | public Object data;
|
---|
33 | /**
|
---|
34 | * An image representation of the clipboard data
|
---|
35 | * (for use when copy/pasting to/from image applications).
|
---|
36 | */
|
---|
37 | public Image imageRepresentation;
|
---|
38 | /**
|
---|
39 | * A string representation of the clipboard data
|
---|
40 | * (for use when copy/pasting to/from text applications).
|
---|
41 | */
|
---|
42 | public String stringRepresentation;
|
---|
43 |
|
---|
44 | /** Default constructor. */
|
---|
45 | public ClipboardData()
|
---|
46 | {
|
---|
47 | this(null, null, null);
|
---|
48 | }
|
---|
49 |
|
---|
50 | /** Standard constructor. */
|
---|
51 | public ClipboardData(Object data, Image imageRepresentation, String stringRepresentation)
|
---|
52 | {
|
---|
53 | this.data = data;
|
---|
54 | this.imageRepresentation = imageRepresentation;
|
---|
55 | this.stringRepresentation = stringRepresentation;
|
---|
56 | }
|
---|
57 |
|
---|
58 | /** Instantiator for purely-image data. */
|
---|
59 | public static ClipboardData fromImage(Image image)
|
---|
60 | {
|
---|
61 | return new ClipboardData(null, image, null);
|
---|
62 | }
|
---|
63 |
|
---|
64 | /** Instantiator for purely-string data. */
|
---|
65 | public static ClipboardData fromString(String string)
|
---|
66 | {
|
---|
67 | return new ClipboardData(null, null, string);
|
---|
68 | }
|
---|
69 |
|
---|
70 | }
|
---|
71 |
|
---|
72 | }
|
---|